small changes
This commit is contained in:
parent
5e735d6a9a
commit
9e9c1cb562
@ -1,18 +1,19 @@
|
||||
<?php
|
||||
// inspired by https://www.mailgun.com/blog/email/double-opt-in-with-php-mailgun/
|
||||
|
||||
require(dirname(__FILE__) . '/settings.php');
|
||||
require(dirname(__FILE__) . '/../settings.php');
|
||||
|
||||
$successURL = '/newsletter/confirmed.html';
|
||||
$errorURL = '/newsletter/error.html';
|
||||
$successURL = '/confirmed.html';
|
||||
$errorURL = '/error.html';
|
||||
$err = 'Bestätigung fehlgeschlagen';
|
||||
|
||||
|
||||
// Adds new subscriber to database. Returns an error message on failure, TRUE on success.
|
||||
function AddSubscriberToDB($subscriberAddress, $subscriberName = NULL) {
|
||||
$pdo = getPDO();
|
||||
|
||||
// check if record exists
|
||||
$check = NotAlreadySubscribed($subscriberAddress, $pdo);
|
||||
$check = NotYetSubscribed($subscriberAddress, $pdo);
|
||||
if ( gettype($check) == 'string' ) {
|
||||
return $check;
|
||||
}
|
||||
|
||||
@ -1,12 +1,29 @@
|
||||
<?php
|
||||
// inspired by https://www.mailgun.com/blog/email/double-opt-in-with-php-mailgun/
|
||||
|
||||
require(dirname(__FILE__) . '/settings.php');
|
||||
require(dirname(__FILE__) . '/../settings.php');
|
||||
|
||||
$successURL = '/newsletter/success.html';
|
||||
$errorURL = '/newsletter/error.html';
|
||||
$successURL = '/success.html';
|
||||
$errorURL = '/error.html';
|
||||
$err = 'Anmeldung fehlgeschlagen';
|
||||
|
||||
// body template for confirmation email
|
||||
$bodyConfirmation = [
|
||||
'Hallo!',
|
||||
'Bitte bestätige die Anmeldung für meinen Newsletter, indem du auf den folgenden Link klickst:',
|
||||
'%Placeholder%',
|
||||
'Bis bald und viele Grüße, Tobias'
|
||||
];
|
||||
|
||||
// contents of confirmation email
|
||||
$mailConfirmation = [
|
||||
'subject' => 'Newsletter-Anmeldung bestaetigen',
|
||||
'bodyHTML' => '<p>' . implode('</p><p>', $bodyConfirmation) . '</p>',
|
||||
'bodyText' => implode("\n\n", $bodyConfirmation),
|
||||
'fromAddress' => '***REMOVED***', // 'newsletter@tobias-radloff.de'
|
||||
'fromName' => 'Tobias Radloffs Newsletter'
|
||||
];
|
||||
|
||||
// check if email parameter is set
|
||||
if ( ! isset($_POST['email']) ) {
|
||||
GracefulExit($errorURL, "{$err}: Keine Emailadresse angegeben.");
|
||||
@ -20,7 +37,7 @@ if ( ! filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
|
||||
// check whether address is already subscribed
|
||||
try {
|
||||
$check = NotAlreadySubscribed($email);
|
||||
$check = NotYetSubscribed($email);
|
||||
if ( gettype($check) == 'string' ) {
|
||||
GracefulExit($errorURL, "{$err}: {$check}.");
|
||||
}
|
||||
@ -28,11 +45,15 @@ try {
|
||||
GracefulExit($errorURL, "{$err}: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
// send email with confirmation link
|
||||
// build and add link to
|
||||
$confirmQuery = http_build_query(['c' => GetConfirmationHash($email), 'e' => $email]);
|
||||
$confirmLink = $general['siteURL'] . $general['confirmScript'] . "?" . $confirmQuery;
|
||||
$mailConfirmation['bodyHTML'] = str_replace('%Placeholder%', $confirmLink, $mailConfirmation['bodyHTML']);
|
||||
$mailConfirmation['bodyText'] = str_replace('%Placeholder%', $confirmLink, $mailConfirmation['bodyText']);
|
||||
|
||||
// send email
|
||||
try {
|
||||
SendEmail($email, $mailConfirmation, $confirmLink);
|
||||
SendEmail($email, $mailConfirmation);
|
||||
} catch (Exception $e) {
|
||||
GracefulExit($errorURL, "{$err}: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
<?php
|
||||
|
||||
require(dirname(__FILE__) . '/settings.php');
|
||||
require(dirname(__FILE__) . '/../settings.php');
|
||||
|
||||
$successURL = '/newsletter/success.html';
|
||||
$errorURL = '/newsletter/error.html';
|
||||
$successURL = '/success.html';
|
||||
$errorURL = '/error.html';
|
||||
$err = "Abmeldung fehlgeschlagen";
|
||||
|
||||
function RemoveSubscriberFromDB($subscriberAddress) {
|
||||
$pdo = getPDO();
|
||||
|
||||
// make sure record exists
|
||||
$check = NotAlreadySubscribed($subscriberAddress, $pdo);
|
||||
if ( gettype($check) == 'string' ) {
|
||||
$check = NotYetSubscribed($subscriberAddress, $pdo);
|
||||
if ( gettype($check) == 'boolean' ) {
|
||||
return "Emailadresse {$subscriberAddress} ist unbekannt";
|
||||
} elseif ( gettype($check) == 'string' and $check != "Emailadresse {$subscriberAddress} ist bereits eingetragen") {
|
||||
return $check;
|
||||
}
|
||||
|
||||
@ -45,4 +47,7 @@ try {
|
||||
} catch(\PDOException $e) {
|
||||
GracefulExit($error, "{$err}: {$e->getMessage()}");
|
||||
}
|
||||
|
||||
// success
|
||||
GracefulExit($successURL, 'Abmeldung erfolgt: Emailadresse ist aus dem Newsletter ausgetragen');
|
||||
?>
|
||||
@ -356,6 +356,7 @@ pre {
|
||||
|
||||
.card-body img {
|
||||
height: var(--card-height);
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user