| Server IP : 188.114.96.3 / Your IP : 216.73.216.143 Web Server : Apache System : Linux sv058.home.net.pl 6.8.2 husak_dirty_pages_fix #1 SMP PREEMPT_DYNAMIC Tue Apr 2 22:06:51 CEST 2024 x86_64 User : ( 3194769) PHP Version : 8.5.12 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /polana/ |
Upload File : |
<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/newsletter.php';
$title = 'Newsletter | Moja Polana Smaków';
$description = 'Zapisz się do newslettera Mojej Polany Smaków i bądź na bieżąco z menu, wydarzeniami i nowościami.';
$canonical = '/newsletter.php';
$ok = false;
$message = '';
$mode = 'subscribe';
if (isset($_GET['unsubscribe'])) {
$mode = 'unsubscribe';
try {
$ok = newsletter_unsubscribe((string)$_GET['unsubscribe']);
$message = $ok
? 'Adres został wypisany z newslettera.'
: 'Nie udało się odnaleźć aktywnego zapisu dla tego linku.';
} catch (Throwable $e) {
$message = 'Nie udało się teraz przetworzyć wypisu.';
error_log('[POLANA NEWSLETTER unsubscribe] '.$e->getMessage());
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (empty($_POST['newsletter_consent'])) {
$message = 'Zaznacz zgodę na newsletter.';
} else {
try {
$r = newsletter_subscribe(
(string)($_POST['email'] ?? ''),
(string)($_POST['name'] ?? ''),
(string)($_POST['source'] ?? 'footer')
);
$ok = (bool)($r['ok'] ?? false);
$message = (string)($r['message'] ?? '');
} catch (Throwable $e) {
$message = 'Nie udało się teraz zapisać do newslettera. Spróbuj ponownie później.';
error_log('[POLANA NEWSLETTER subscribe] '.$e->getMessage());
}
}
}
render_public_head($title,$description,$canonical);
render_public_header('');
?>
<main class="newsletter-page">
<section class="newsletter-page__card">
<p class="newsletter-page__eyebrow">Moja Polana Smaków</p>
<h1><?= $mode === 'unsubscribe' ? 'Newsletter' : 'Dołącz do newslettera' ?></h1>
<div class="newsletter-page__message <?= $ok ? 'is-ok' : 'is-info' ?>">
<?= e($message !== '' ? $message : 'Zapisz się, żeby być na bieżąco z tym, co dzieje się na Polanie.') ?>
</div>
<?php if (!$ok && $mode !== 'unsubscribe'): ?>
<form class="newsletter-page__form" method="post" action="<?= e(polana_local_path('/newsletter.php')) ?>">
<label>E-mail
<input type="email" name="email" required autocomplete="email">
</label>
<label>Imię <span>(opcjonalnie)</span>
<input type="text" name="name" maxlength="150" autocomplete="given-name">
</label>
<label class="newsletter-consent">
<input type="checkbox" name="newsletter_consent" value="1" required>
<span>Chcę otrzymywać newsletter Mojej Polany Smaków z informacjami o menu, wydarzeniach i nowościach. Zgoda jest dobrowolna i mogę ją wycofać w każdej chwili.</span>
</label>
<input type="hidden" name="source" value="newsletter-page">
<button type="submit">Zapisz mnie</button>
</form>
<?php endif; ?>
<p class="newsletter-page__back"><a href="/">← Wróć na Polanę</a></p>
</section>
</main>
<?php render_public_footer(); ?>