debugging rsvp-submit.php
This commit is contained in:
1 parent
8da8789b50
commit
efec4b783c
6 files changed
+236
-33
No files matched your search
@@ -137,14 +137,14 @@
|
||||
|
||||
|
||||
<li class="navigation-item">
|
||||
<a href="/ru/categories/">🇷🇺</a>
|
||||
<a href="/categories/">🇬🇧</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="navigation-item">
|
||||
<a href="/categories/">🇬🇧</a>
|
||||
<a href="/ru/categories/">🇷🇺</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,6 @@
|
||||
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||
<url>
|
||||
<loc>http://markinstefan.xyz/de/authors/</loc>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="de"
|
||||
href="http://markinstefan.xyz/de/authors/"
|
||||
/>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="en"
|
||||
@@ -18,13 +13,13 @@
|
||||
hreflang="ru"
|
||||
href="http://markinstefan.xyz/ru/authors/"
|
||||
/>
|
||||
</url><url>
|
||||
<loc>http://markinstefan.xyz/de/categories/</loc>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="ru"
|
||||
href="http://markinstefan.xyz/ru/categories/"
|
||||
hreflang="de"
|
||||
href="http://markinstefan.xyz/de/authors/"
|
||||
/>
|
||||
</url><url>
|
||||
<loc>http://markinstefan.xyz/de/categories/</loc>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="de"
|
||||
@@ -35,6 +30,11 @@
|
||||
hreflang="en"
|
||||
href="http://markinstefan.xyz/categories/"
|
||||
/>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="ru"
|
||||
href="http://markinstefan.xyz/ru/categories/"
|
||||
/>
|
||||
</url><url>
|
||||
<loc>http://markinstefan.xyz/de/hochzeit/</loc>
|
||||
<xhtml:link
|
||||
|
||||
@@ -139,11 +139,6 @@
|
||||
/>
|
||||
</url><url>
|
||||
<loc>http://markinstefan.xyz/tags/</loc>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="en"
|
||||
href="http://markinstefan.xyz/tags/"
|
||||
/>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="ru"
|
||||
@@ -154,5 +149,10 @@
|
||||
hreflang="de"
|
||||
href="http://markinstefan.xyz/de/tags/"
|
||||
/>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="en"
|
||||
href="http://markinstefan.xyz/tags/"
|
||||
/>
|
||||
</url>
|
||||
</urlset>
|
||||
@@ -14,15 +14,6 @@ $dotenv->safeLoad();
|
||||
|
||||
file_put_contents('/tmp/rsvp-debug.log', "3\n", FILE_APPEND);
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use Dotenv\Dotenv;
|
||||
|
||||
$dotenv = Dotenv::createImmutable(__DIR__ . '/../');
|
||||
$dotenv->safeLoad();
|
||||
|
||||
function checkboxArrayToString($value)
|
||||
{
|
||||
if (is_array($value) && count($value) > 0) {
|
||||
|
||||
@@ -54,6 +54,11 @@
|
||||
/>
|
||||
</url><url>
|
||||
<loc>http://markinstefan.xyz/ru/tags/</loc>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="ru"
|
||||
href="http://markinstefan.xyz/ru/tags/"
|
||||
/>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="de"
|
||||
@@ -64,11 +69,6 @@
|
||||
hreflang="en"
|
||||
href="http://markinstefan.xyz/tags/"
|
||||
/>
|
||||
<xhtml:link
|
||||
rel="alternate"
|
||||
hreflang="ru"
|
||||
href="http://markinstefan.xyz/ru/tags/"
|
||||
/>
|
||||
</url><url>
|
||||
<loc>http://markinstefan.xyz/ru/contact/</loc>
|
||||
<xhtml:link
|
||||
|
||||
+215
-3
@@ -1,6 +1,218 @@
|
||||
<?php
|
||||
|
||||
file_put_contents('/tmp/rsvp-post.log', print_r($_POST, true));
|
||||
file_put_contents('/tmp/rsvp-debug.log', "1\n", FILE_APPEND);
|
||||
|
||||
echo "POST OK";
|
||||
exit;
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
file_put_contents('/tmp/rsvp-debug.log', "2\n", FILE_APPEND);
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
use Dotenv\Dotenv;
|
||||
|
||||
$dotenv = Dotenv::createImmutable(__DIR__ . '/../');
|
||||
$dotenv->safeLoad();
|
||||
|
||||
file_put_contents('/tmp/rsvp-debug.log', "3\n", FILE_APPEND);
|
||||
|
||||
function checkboxArrayToString($value)
|
||||
{
|
||||
if (is_array($value) && count($value) > 0) {
|
||||
return implode(', ', $value);
|
||||
}
|
||||
return 'None';
|
||||
}
|
||||
|
||||
function yesNo($value)
|
||||
{
|
||||
return !empty($value) ? 'Yes' : 'No';
|
||||
}
|
||||
|
||||
// Honeypot spam protection
|
||||
if (!empty($_POST['website'])) {
|
||||
exit('Spam detected.');
|
||||
}
|
||||
|
||||
// Privacy consent required
|
||||
if (empty($_POST['privacy'])) {
|
||||
exit('Privacy consent required.');
|
||||
}
|
||||
|
||||
// Personal
|
||||
$first_name = trim($_POST['first_name'] ?? '');
|
||||
$last_name = trim($_POST['last_name'] ?? '');
|
||||
$name = trim("$first_name $last_name");
|
||||
|
||||
$email = trim($_POST['email'] ?? '');
|
||||
$phone = trim($_POST['phone'] ?? '');
|
||||
|
||||
// Attendance
|
||||
$attendance = $_POST['attendance'] ?? 'Unknown';
|
||||
|
||||
// Drinks
|
||||
$drinks = checkboxArrayToString($_POST['drinks'] ?? []);
|
||||
|
||||
// Diet
|
||||
$diet = $_POST['diet'] ?? 'Not specified';
|
||||
|
||||
// Allergies
|
||||
$allergies = checkboxArrayToString($_POST['allergies'] ?? []);
|
||||
$allergies_other = trim($_POST['allergies_other'] ?? '');
|
||||
|
||||
// Organization
|
||||
$parking = yesNo($_POST['parking'] ?? '');
|
||||
$ride_needed = yesNo($_POST['ride_needed'] ?? '');
|
||||
$ride_offer = yesNo($_POST['ride_offer'] ?? '');
|
||||
$hotel = yesNo($_POST['hotel'] ?? '');
|
||||
$hotel_booked = yesNo($_POST['hotel_booked'] ?? '');
|
||||
|
||||
// Memories
|
||||
$memory_card = yesNo($_POST['memory_card'] ?? '');
|
||||
$photo_link = yesNo($_POST['photo_link'] ?? '');
|
||||
|
||||
// Entertainment
|
||||
$music_request = trim($_POST['music_request'] ?? '');
|
||||
$contribution = checkboxArrayToString($_POST['contribution'] ?? []);
|
||||
|
||||
// Children
|
||||
$children = $_POST['children'] ?? 'No';
|
||||
$children_count = trim($_POST['children_count'] ?? '');
|
||||
$children_ages = trim($_POST['children_ages'] ?? '');
|
||||
|
||||
// Message
|
||||
$message = trim($_POST['message'] ?? '');
|
||||
|
||||
// UTF-8 conversion
|
||||
$fields = [
|
||||
&$name,
|
||||
&$email,
|
||||
&$phone,
|
||||
&$attendance,
|
||||
&$drinks,
|
||||
&$diet,
|
||||
&$allergies,
|
||||
&$allergies_other,
|
||||
&$music_request,
|
||||
&$contribution,
|
||||
&$children,
|
||||
&$children_count,
|
||||
&$children_ages,
|
||||
&$message
|
||||
];
|
||||
|
||||
foreach ($fields as &$field) {
|
||||
$field = mb_convert_encoding($field, 'UTF-8', 'auto');
|
||||
}
|
||||
|
||||
file_put_contents('/tmp/rsvp-debug.log', "4\n", FILE_APPEND);
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try {
|
||||
|
||||
$mail->CharSet = 'UTF-8';
|
||||
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $_ENV['SMTP_HOST'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $_ENV['SMTP_USER'];
|
||||
$mail->Password = $_ENV['SMTP_PASS'];
|
||||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
|
||||
$mail->Port = (int)$_ENV['SMTP_PORT'];
|
||||
|
||||
$mail->setFrom($_ENV['FROM_EMAIL'], $_ENV['FROM_NAME']);
|
||||
$mail->addAddress($_ENV['TO_EMAIL']);
|
||||
|
||||
$mail->Subject = mb_encode_mimeheader(
|
||||
"Wedding RSVP: $name",
|
||||
'UTF-8'
|
||||
);
|
||||
|
||||
$body = <<<EOD
|
||||
==================================================
|
||||
PERSONAL INFORMATION
|
||||
==================================================
|
||||
|
||||
Name: $name
|
||||
Email: $email
|
||||
Phone: $phone
|
||||
|
||||
==================================================
|
||||
ATTENDANCE
|
||||
==================================================
|
||||
|
||||
Attendance: $attendance
|
||||
|
||||
==================================================
|
||||
DRINKS
|
||||
==================================================
|
||||
|
||||
Preferred Drinks: $drinks
|
||||
|
||||
==================================================
|
||||
FOOD
|
||||
==================================================
|
||||
|
||||
Diet: $diet
|
||||
|
||||
Allergies: $allergies
|
||||
Additional Details: $allergies_other
|
||||
|
||||
==================================================
|
||||
ORGANIZATION
|
||||
==================================================
|
||||
|
||||
Parking Needed: $parking
|
||||
Needs Ride: $ride_needed
|
||||
Can Offer Ride: $ride_offer
|
||||
Hotel Stay: $hotel
|
||||
Hotel Booked: $hotel_booked
|
||||
|
||||
==================================================
|
||||
MEMORIES & EXTRAS
|
||||
==================================================
|
||||
|
||||
Greeting Card: $memory_card
|
||||
Wedding Photo Link: $photo_link
|
||||
|
||||
==================================================
|
||||
ENTERTAINMENT
|
||||
==================================================
|
||||
|
||||
Song Request: $music_request
|
||||
|
||||
Contribution:
|
||||
$contribution
|
||||
|
||||
==================================================
|
||||
CHILDREN
|
||||
==================================================
|
||||
|
||||
Coming with Children: $children
|
||||
Number of Children: $children_count
|
||||
Children Ages: $children_ages
|
||||
|
||||
==================================================
|
||||
MESSAGE
|
||||
==================================================
|
||||
|
||||
$message
|
||||
|
||||
EOD;
|
||||
|
||||
$mail->Body = $body;
|
||||
|
||||
file_put_contents('/tmp/rsvp-debug.log', "5\n", FILE_APPEND);
|
||||
$mail->SMTPDebug = 2;
|
||||
$mail->Debugoutput = 'error_log';
|
||||
$mail->Timeout = 10;
|
||||
error_log("About to send mail");
|
||||
$mail->send();
|
||||
error_log("Mail sent");
|
||||
file_put_contents('/tmp/rsvp-debug.log', "6\n", FILE_APPEND);
|
||||
|
||||
header('Location: /thank-you/');
|
||||
exit;
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
echo "RSVP could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
}
|
||||
Reference in new issue
Block a user