177 lines
9.6 KiB
PHP
177 lines
9.6 KiB
PHP
<?php
|
|
require_once __DIR__ . '/webinar_schedule.php';
|
|
|
|
function webinar_join_url(): string {
|
|
return 'https://meet.google.com/ohs-ayvx-dqg';
|
|
}
|
|
|
|
function webinar_base_url(): string {
|
|
$isHttps = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
|
|
$protocol = $isHttps ? 'https' : 'http';
|
|
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
|
|
|
return $protocol . '://' . $host;
|
|
}
|
|
|
|
function webinar_logo_url(): string {
|
|
return webinar_base_url() . '/assets/pasted-20251030-095744-1b7c02ab.png';
|
|
}
|
|
|
|
function webinar_calendar_description(array $schedule): string {
|
|
return implode("
|
|
|
|
", [
|
|
'Professional Vibe-Coding Webinar',
|
|
'Join us on ' . $schedule['date_long'] . ' at ' . $schedule['timezone_line'] . '.',
|
|
'Google Meet link: ' . webinar_join_url(),
|
|
'The fastest way to go from an idea to a working app you own, running on your server, with your database, using real frameworks.',
|
|
]);
|
|
}
|
|
|
|
function webinar_google_calendar_link(array $schedule): string {
|
|
$eventTitle = $schedule['title'];
|
|
$eventDescription = webinar_calendar_description($schedule);
|
|
$startTimeUtc = webinar_utc_stamp($schedule['start']);
|
|
$endTimeUtc = webinar_utc_stamp($schedule['end']);
|
|
|
|
return 'https://www.google.com/calendar/render?action=TEMPLATE'
|
|
. '&text=' . urlencode($eventTitle)
|
|
. '&dates=' . $startTimeUtc . '/' . $endTimeUtc
|
|
. '&details=' . urlencode($eventDescription)
|
|
. '&location=' . urlencode(webinar_join_url())
|
|
. '&ctz=UTC';
|
|
}
|
|
|
|
function webinar_outlook_calendar_link(array $schedule): string {
|
|
$eventTitle = $schedule['title'];
|
|
$eventDescription = webinar_calendar_description($schedule);
|
|
$icsContent = implode("
|
|
", [
|
|
'BEGIN:VCALENDAR',
|
|
'VERSION:2.0',
|
|
'PRODID:-//Flatlogic//' . $eventTitle . '//EN',
|
|
'BEGIN:VEVENT',
|
|
'URL:' . webinar_base_url(),
|
|
'DTSTART:' . webinar_utc_stamp($schedule['start']),
|
|
'DTEND:' . webinar_utc_stamp($schedule['end']),
|
|
'SUMMARY:' . $eventTitle,
|
|
'DESCRIPTION:' . str_replace(PHP_EOL, '\n', $eventDescription),
|
|
'LOCATION:' . webinar_join_url(),
|
|
'END:VEVENT',
|
|
'END:VCALENDAR',
|
|
]);
|
|
|
|
return 'data:text/calendar;charset=utf-8,' . rawurlencode($icsContent);
|
|
}
|
|
|
|
function webinar_build_email_payload(string $firstName, array $webinar, bool $isCorrection = false): array {
|
|
$schedule = webinar_schedule_data($webinar);
|
|
$eventTitle = $schedule['title'];
|
|
$googleLink = webinar_google_calendar_link($schedule);
|
|
$outlookLink = webinar_outlook_calendar_link($schedule);
|
|
$joinUrl = webinar_join_url();
|
|
$baseUrl = webinar_base_url();
|
|
$logoUrl = webinar_logo_url();
|
|
|
|
$safeFirstName = htmlspecialchars(trim($firstName) !== '' ? $firstName : 'there', ENT_QUOTES, 'UTF-8');
|
|
$safeTitle = htmlspecialchars($eventTitle, ENT_QUOTES, 'UTF-8');
|
|
$safeDateLong = htmlspecialchars($schedule['date_long'], ENT_QUOTES, 'UTF-8');
|
|
$safeBerlinLabel = htmlspecialchars($schedule['berlin_label'], ENT_QUOTES, 'UTF-8');
|
|
$safeNewYorkLabel = htmlspecialchars($schedule['new_york_label'], ENT_QUOTES, 'UTF-8');
|
|
$safeLosAngelesLabel = htmlspecialchars($schedule['los_angeles_label'], ENT_QUOTES, 'UTF-8');
|
|
$safeJoinUrl = htmlspecialchars($joinUrl, ENT_QUOTES, 'UTF-8');
|
|
|
|
if ($isCorrection) {
|
|
$subject = 'Updated webinar time and join link for ' . $eventTitle;
|
|
$introHtml = '<p style="font-size: 16px; line-height: 1.6;">We updated the webinar timing to reflect U.S. daylight saving time. Please use the corrected schedule and links below.</p>';
|
|
$noteHtml = '<p style="font-size: 16px; line-height: 1.6;"><strong>If you already saved the older calendar event, please remove it and add the updated one from this email.</strong></p>';
|
|
$headline = 'Updated Webinar Details';
|
|
$introText = 'We updated the webinar timing to reflect U.S. daylight saving time. Please use the corrected schedule and links below.';
|
|
$noteText = 'If you already saved the older calendar event, please remove it and add the updated one from this email.';
|
|
} else {
|
|
$subject = "Confirmation: You're Registered for {$eventTitle}";
|
|
$introHtml = '<p style="font-size: 16px; line-height: 1.6;">Thank you for registering for the <strong>' . $safeTitle . '</strong> webinar.</p><p style="font-size: 16px; line-height: 1.6;">We are excited to have you join us for this professional vibe-coding session.</p>';
|
|
$noteHtml = '<p style="font-size: 16px; line-height: 1.6;"><strong>Your webinar link is below, and you can add the corrected event to your calendar right now.</strong></p>';
|
|
$headline = "You're Registered!";
|
|
$introText = 'Thank you for registering for the ' . $eventTitle . ' webinar. We are excited to have you join us for this professional vibe-coding session.';
|
|
$noteText = 'Your webinar link is below, and you can add the corrected event to your calendar right now.';
|
|
}
|
|
|
|
$bodyHtml = <<<HTML
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{$safeTitle}</title>
|
|
</head>
|
|
<body style="font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f4f4f4; color: #333; margin: 0; padding: 0;">
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="background-color: #f4f4f4;">
|
|
<tr>
|
|
<td align="center">
|
|
<table width="600" border="0" cellspacing="0" cellpadding="0" style="background-color: #ffffff; margin: 20px auto; border-radius: 10px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); overflow: hidden;">
|
|
<tr>
|
|
<td align="center" style="padding: 40px 20px; background: linear-gradient(135deg, #1a237e 0%, #0f9fff 100%);">
|
|
<img src="{$logoUrl}" alt="AppWizzy Logo" style="height: 60px; margin-bottom: 20px;">
|
|
<h1 style="color: #ffffff; font-size: 28px; margin: 0; line-height: 1.2;">{$headline}</h1>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="padding: 40px 30px;">
|
|
<h2 style="font-size: 22px; color: #1a237e; margin-top: 0;">Hello {$safeFirstName},</h2>
|
|
{$introHtml}
|
|
<div style="background-color: #f9f9f9; border-left: 4px solid #0f9fff; padding: 15px 20px; margin: 20px 0;">
|
|
<p style="margin: 0; font-size: 16px;"><strong>Webinar details</strong></p>
|
|
<p style="margin: 10px 0 0; font-size: 16px;">{$safeDateLong} | <strong>{$safeBerlinLabel}</strong> | {$safeNewYorkLabel} | {$safeLosAngelesLabel}</p>
|
|
</div>
|
|
<p style="font-size: 16px; line-height: 1.6;">Join the live session here:</p>
|
|
<p style="font-size: 16px; line-height: 1.8; word-break: break-word;"><a href="{$safeJoinUrl}" style="color: #0f62fe;">{$safeJoinUrl}</a></p>
|
|
{$noteHtml}
|
|
<p style="text-align: center; margin: 30px 0 12px;">
|
|
<a href="{$safeJoinUrl}" style="display: inline-block; background: linear-gradient(135deg, #0f62fe 0%, #0f9fff 100%); color: #ffffff; padding: 12px 25px; text-decoration: none; border-radius: 8px; font-weight: 700; margin: 0 8px 12px;">Join Webinar</a>
|
|
<a href="{$googleLink}" style="display: inline-block; background: linear-gradient(135deg, #1a237e 0%, #4b5bdc 100%); color: #ffffff; padding: 12px 25px; text-decoration: none; border-radius: 8px; font-weight: 700; margin: 0 8px 12px;">Add to Google Calendar</a>
|
|
</p>
|
|
<p style="text-align: center; margin: 0 0 12px;">
|
|
<a href="{$outlookLink}" style="color: #1a237e; font-weight: 600; text-decoration: none;">Download calendar file (.ics)</a>
|
|
</p>
|
|
<p style="font-size: 16px; line-height: 1.6;">You'll learn the fastest way to go from an idea to a working app you own, running on your server, with your database, using real frameworks.</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" style="padding: 20px; background-color: #f4f4f4; border-top: 1px solid #dddddd;">
|
|
<p style="margin: 0; color: #777;">© 2026 AppWizzy. All rights reserved.</p>
|
|
<p style="margin: 5px 0 0; color: #777;">You can <a href="{$baseUrl}" style="color: #0f62fe;">visit our website</a> for more information.</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|
|
HTML;
|
|
|
|
$textBody = implode("
|
|
|
|
", [
|
|
'Hello ' . (trim($firstName) !== '' ? trim($firstName) : 'there') . ',',
|
|
$introText,
|
|
'Webinar details: ' . $schedule['date_long'] . ' | ' . $schedule['berlin_label'] . ' | ' . $schedule['new_york_label'] . ' | ' . $schedule['los_angeles_label'],
|
|
'Join webinar: ' . $joinUrl,
|
|
$noteText,
|
|
'Add to Google Calendar: ' . $googleLink,
|
|
'Download calendar file (.ics): ' . $outlookLink,
|
|
]);
|
|
|
|
return [
|
|
'subject' => $subject,
|
|
'html' => $bodyHtml,
|
|
'text' => $textBody,
|
|
'schedule' => $schedule,
|
|
'google_link' => $googleLink,
|
|
'outlook_link' => $outlookLink,
|
|
'join_url' => $joinUrl,
|
|
'event_title' => $eventTitle,
|
|
];
|
|
}
|