38 lines
1.2 KiB
PHP
38 lines
1.2 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 AddMemberToDB($recipientAddress) {
|
|
global $db;
|
|
echo "ah jup";
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
require(dirname(__FILE__) . "/settings.php");
|
|
|
|
$c = isset($_GET['c']) ? SanitizeInputs($_GET['c']) : NULL;
|
|
$e = isset($_GET['e']) ? SanitizeInputs($_GET['e']) : NULL;
|
|
|
|
if (! (isset($c) && isset($e) && CheckConfirmationHash($e, $c)) ) {
|
|
header($statusCode);
|
|
header("Location: " . $errorURL . "?" . http_build_query(["msg" => SanitizeInputs("Ungültiger Link")]));
|
|
} else {
|
|
$result = AddMemberToDB($e);
|
|
if ($result == TRUE) {
|
|
header($statusCode);
|
|
header("Location: " . $successURL);
|
|
} elseif (gettype($result == "string")) {
|
|
header($statusCode);
|
|
header("Location: " . $errorURL . "?" . http_build_query(["msg" => SanitizeInputs($result)]));
|
|
} else {
|
|
header($statusCode);
|
|
header("Location: " . $errorURL . "?" . http_build_query(["msg" => SanitizeInputs("Unbekannter Fehler")]));
|
|
}
|
|
}
|
|
?>
|