41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
// inspired by https://www.mailgun.com/blog/email/double-opt-in-with-php-mailgun/
|
|
$statusCode = 'HTTP/1.1 303 See Other';
|
|
$successURL = '/newsletter/confirmed.html';
|
|
$errorURL = '/newsletter/confirm-error.html';
|
|
|
|
// return TRUE when successful, message string on failure
|
|
// e.g. Adresse schon vorhanden, Datenbank-Fehler, was noch?
|
|
function AddSubscriberToDB($recipientAddress) {
|
|
global $db;
|
|
echo 'ah jup';
|
|
return TRUE;
|
|
}
|
|
|
|
function CheckConfirmationHash($confEmail, $confCode) {
|
|
global $general;
|
|
return (md5($confEmail . $general['uniqueKey']) === $confCode);
|
|
}
|
|
|
|
require(dirname(__FILE__) . '/settings.php');
|
|
|
|
if (isset($_GET['c']) && isset($_GET['e'])) {
|
|
$c = filter_var($_GET['c'], FILTER_SANITIZE_STRING);
|
|
$e = filter_var($_GET['e'], FILTER_SANITIZE_STRING);
|
|
|
|
if (CheckConfirmationHash($e, $c)) {
|
|
$result = AddSubscriberToDB($e);
|
|
if ($result == TRUE) {
|
|
GracefulExit($successURL, 'Bestätigung erfolgt: Newsletter-Anmeldung bestätigt');
|
|
} elseif (gettype($result == 'string')) {
|
|
GracefulExit($errorURL, "Bestätigung fehlgeschlagen: {$result}");
|
|
} else {
|
|
GracefulExit($errorURL, 'Bestätigung fehlgeschlagen: Unbekannter Fehler');
|
|
}
|
|
} else {
|
|
GracefulExit($errorURL, 'Bestätigung fehlgeschlagen: Fehlerhafter Hash');
|
|
}
|
|
} else {
|
|
GracefulExit($errorURL, 'Bestätigung fehlgeschlagen: Fehlende Emailadresse oder Hash');
|
|
}
|
|
?>
|