195 lines
7.0 KiB
PHP
195 lines
7.0 KiB
PHP
<?php
|
||
/**
|
||
* Carteasy – Landingpage Widerruf (EU-RL 2026/2673)
|
||
*
|
||
* GET ?t=<token> → Token validieren, Widerrufs-Formular anzeigen
|
||
* POST → Widerruf erfassen, Bestätigungsseite anzeigen
|
||
*
|
||
* Standalone-Entry-Point, nutzt das Shop-Base-Objekt für DB + Config.
|
||
*
|
||
* @copyright Wlanium / Thomas Bartelt
|
||
* @since 2026-04-19
|
||
*/
|
||
|
||
session_start();
|
||
ini_set('display_errors', 0);
|
||
error_reporting(0);
|
||
ini_set('log_errors', 1);
|
||
ini_set('error_log', __DIR__.'/error_log.txt');
|
||
|
||
header('X-Robots-Tag: noindex, nofollow', true);
|
||
header('Content-Security-Policy: default-src \'self\'; style-src \'unsafe-inline\'');
|
||
|
||
include_once './core/base.class.php';
|
||
include_once './core/registry.class.php';
|
||
$base_object = new base();
|
||
Registry::set('base', $base_object);
|
||
|
||
include_once './core/revocation.class.php';
|
||
|
||
$revocation = new Revocation($base_object);
|
||
|
||
$view = 'form';
|
||
$payload = null;
|
||
$error = null;
|
||
|
||
// ------------------------------------------------------------
|
||
// Request dispatch
|
||
// ------------------------------------------------------------
|
||
|
||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
|
||
$token = isset($_POST['t']) ? (string)$_POST['t'] : '';
|
||
$reason_id = isset($_POST['reason_id']) ? (int)$_POST['reason_id'] : 0;
|
||
$reason_text = isset($_POST['reason_text']) ? (string)$_POST['reason_text'] : '';
|
||
$confirm = isset($_POST['confirm']) && $_POST['confirm'] === '1';
|
||
|
||
if (!$confirm) {
|
||
// Zweite Stufe nicht aktiv bestätigt → zurück zum Form mit Hinweis
|
||
$payload = $revocation->validate_token($token);
|
||
if ($payload) {
|
||
$view = 'form';
|
||
$error = 'Bitte bestätigen Sie den Widerruf durch Setzen des Hakens.';
|
||
} else {
|
||
$view = 'error';
|
||
$error = $revocation->get_error();
|
||
}
|
||
} else {
|
||
$ip = $_SERVER['REMOTE_ADDR'] ?? '';
|
||
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||
if ($revocation->submit($token, $reason_id, $reason_text, $ip, $ua)) {
|
||
$view = 'success';
|
||
} else {
|
||
$view = 'error';
|
||
$error = $revocation->get_error();
|
||
}
|
||
}
|
||
|
||
} else {
|
||
|
||
$token = isset($_GET['t']) ? (string)$_GET['t'] : '';
|
||
$payload = $revocation->validate_token($token);
|
||
if (!$payload) {
|
||
$view = 'error';
|
||
$error = $revocation->get_error();
|
||
}
|
||
}
|
||
|
||
// ------------------------------------------------------------
|
||
// View rendering
|
||
// ------------------------------------------------------------
|
||
|
||
$reasons = $revocation->fetch_reasons();
|
||
|
||
?><!doctype html>
|
||
<html lang="de">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<meta name="robots" content="noindex,nofollow">
|
||
<title>Widerruf – Intelectra</title>
|
||
<style>
|
||
body {font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
|
||
background:#f6f6f6;margin:0;color:#222;}
|
||
.wrap{max-width:640px;margin:40px auto;padding:32px;background:#fff;
|
||
border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,.08);}
|
||
h1{margin-top:0;color:#c00;}
|
||
h2{margin-top:1.6em;}
|
||
.meta{background:#f4f4f4;padding:12px 16px;border-left:4px solid #c00;
|
||
font-size:.9em;margin:16px 0;}
|
||
label{display:block;margin:12px 0 4px;font-weight:600;}
|
||
select,textarea,input[type=text]{width:100%;padding:10px;font-size:1em;
|
||
border:1px solid #ccc;border-radius:4px;box-sizing:border-box;}
|
||
textarea{min-height:90px;font-family:inherit;}
|
||
.check{margin:20px 0;font-size:.95em;}
|
||
.btn{background:#c00;color:#fff;border:0;padding:14px 28px;
|
||
font-size:1.05em;font-weight:bold;border-radius:4px;cursor:pointer;}
|
||
.btn:hover{background:#a00;}
|
||
.err{background:#ffe9e9;border-left:4px solid #c00;padding:10px 14px;
|
||
margin:12px 0;}
|
||
.ok{background:#e7f7e7;border-left:4px solid #2a7;padding:14px 18px;}
|
||
.muted{color:#666;font-size:.85em;}
|
||
footer{text-align:center;margin:20px 0;color:#999;font-size:.8em;}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="wrap">
|
||
|
||
<?php if ($view === 'form'): ?>
|
||
|
||
<h1>Widerruf Ihrer Bestellung</h1>
|
||
<p>Gemäß § 355 BGB haben Sie das Recht, Ihren Vertrag binnen 14 Tagen
|
||
ohne Angabe von Gründen zu widerrufen.</p>
|
||
|
||
<div class="meta">
|
||
<strong>Bestellnummer:</strong> <?= htmlspecialchars($payload->order_number ?? ('#'.$payload->order_id)) ?><br>
|
||
<strong>Bestelldatum:</strong> <?= htmlspecialchars($payload->order_date ?? '–') ?><br>
|
||
<strong>E-Mail:</strong> <?= htmlspecialchars($payload->customer_email) ?>
|
||
</div>
|
||
|
||
<?php if ($error): ?><div class="err"><?= htmlspecialchars($error) ?></div><?php endif; ?>
|
||
|
||
<form method="post" action="<?= htmlspecialchars($_SERVER['REQUEST_URI']) ?>">
|
||
<input type="hidden" name="t" value="<?= htmlspecialchars($_GET['t'] ?? $_POST['t'] ?? '') ?>">
|
||
|
||
<label for="reason_id">Grund (optional)</label>
|
||
<select name="reason_id" id="reason_id">
|
||
<option value="0">— bitte wählen —</option>
|
||
<?php foreach ($reasons as $r): ?>
|
||
<option value="<?= (int)$r->id ?>"><?= htmlspecialchars($r->label) ?></option>
|
||
<?php endforeach; ?>
|
||
</select>
|
||
|
||
<label for="reason_text">Anmerkung (optional)</label>
|
||
<textarea name="reason_text" id="reason_text" maxlength="2000"
|
||
placeholder="Sie können uns hier eine Mitteilung hinterlassen – muss nicht."></textarea>
|
||
|
||
<label class="check">
|
||
<input type="checkbox" name="confirm" value="1" required>
|
||
Ich erkläre hiermit den Widerruf meiner oben genannten Bestellung.
|
||
</label>
|
||
|
||
<button type="submit" class="btn">Widerruf jetzt absenden</button>
|
||
|
||
<p class="muted" style="margin-top:20px;">Nach dem Absenden erhalten Sie eine
|
||
Bestätigungs-E-Mail mit der Rücksendeadresse und weiteren Informationen.</p>
|
||
</form>
|
||
|
||
<?php elseif ($view === 'success'): ?>
|
||
|
||
<h1>Widerruf entgegengenommen</h1>
|
||
<div class="ok">
|
||
<strong>Vielen Dank.</strong> Ihre Widerrufserklärung wurde erfasst.
|
||
Sie erhalten in Kürze eine Bestätigungs-E-Mail an die hinterlegte
|
||
Adresse mit der Rücksendeadresse und den nächsten Schritten.
|
||
</div>
|
||
<p class="muted">Bei Rückfragen erreichen Sie uns unter
|
||
<a href="mailto:<?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?>"><?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?></a>.</p>
|
||
|
||
<?php else: ?>
|
||
|
||
<h1>Widerruf nicht möglich</h1>
|
||
<?php
|
||
$messages = [
|
||
'invalid_token' => 'Der Widerrufs-Link ist ungültig oder nicht (mehr) vorhanden.',
|
||
'expired' => 'Der Widerrufs-Link ist abgelaufen. Die 14-tägige Widerrufsfrist '
|
||
. 'zzgl. Puffer wurde überschritten. Wenden Sie sich bitte direkt an uns.',
|
||
'already_submitted'=> 'Für diese Bestellung wurde bereits ein Widerruf erklärt.',
|
||
'feature_disabled' => 'Die elektronische Widerrufsfunktion ist aktuell noch nicht aktiv.',
|
||
'not_eligible' => 'Für diese Bestellung steht der elektronische Widerruf nicht zur Verfügung.',
|
||
];
|
||
$msg = $messages[$error] ?? 'Widerruf zurzeit nicht verarbeitbar.';
|
||
?>
|
||
<div class="err"><?= htmlspecialchars($msg) ?></div>
|
||
<p>Sie können Ihren Widerruf jederzeit auch formlos per E-Mail an
|
||
<a href="mailto:<?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?>"><?= htmlspecialchars(REVOCATION_OWNER_EMAIL) ?></a>
|
||
oder per Brief erklären.</p>
|
||
<p class="muted">Intelectra GmbH · Sachsenring 20 · 94315 Straubing</p>
|
||
|
||
<?php endif; ?>
|
||
|
||
</div>
|
||
<footer>Intelectra Online-Shop · <a href="/">Zurück zum Shop</a></footer>
|
||
</body>
|
||
</html>
|