E-Mails und Druckvorlage im neuen Design
E-Mail:
- Nachrichten werden in ein markentreues HTML-Gerüst gelegt (Tabellen +
Inline-Styles, damit Outlook & Co. es zuverlässig darstellen); die
Kopfleiste nutzt den eingestellten Markenverlauf
- neuer Platzhalter {VOUCHER_CARD} rendert den Code als hervorgehobene
Karte; bestehende Vorlagen mit {VOUCHER_CODE} funktionieren unverändert
weiter, sie werden lediglich eingerahmt
- Zeilenumbrüche der Vorlage werden vor dem Einsetzen der Platzhalter
umgewandelt, Markup aus dem WYSIWYG-Editor bleibt unangetastet
Druck:
- neue Standardvorlage als Ticket mit QR-Code, Code, Gültigkeit und
Anleitung; zentral in Ui::defaultPrintTemplate()
- neuer Platzhalter {QR_CODE}; der QR-Code wird lokal im Browser erzeugt
(qrcodejs aus assets/vendor), auch bei Bulk-Erstellung für jede Karte
- die Druckvorlage ist am Bildschirm ausgeblendet und erscheint nur im
Ausdruck
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
7f1d93debd
commit
e28527ed91
8 changed files with 401 additions and 290 deletions
|
|
@ -239,26 +239,10 @@ $cs = [
|
||||||
'smtp_from_name' => $db->getSetting('smtp_from_name', ''),
|
'smtp_from_name' => $db->getSetting('smtp_from_name', ''),
|
||||||
'system_url' => $db->getSetting('system_url', $autoDetectedUrl),
|
'system_url' => $db->getSetting('system_url', $autoDetectedUrl),
|
||||||
'email_voucher_subject' => $db->getSetting('email_voucher_subject', '{APP_TITLE} - Ihr WLAN-Zugang'),
|
'email_voucher_subject' => $db->getSetting('email_voucher_subject', '{APP_TITLE} - Ihr WLAN-Zugang'),
|
||||||
'email_voucher_body' => $db->getSetting('email_voucher_body', "Hallo,\n\nIhr Code: {VOUCHER_CODE}\n\nGültigkeit: 8h\nGeräte: {MAX_USES}\nSite: {SITE_NAME}"),
|
'email_voucher_body' => $db->getSetting('email_voucher_body', "Hallo,\n\nhier ist Ihr WLAN-Zugangscode:\n{VOUCHER_CARD}\n<strong>Maximale Geräte:</strong> {MAX_USES}<br>\n<strong>Standort:</strong> {SITE_NAME}\n\n{INSTRUCTIONS}\n\nViele Grüße\n{APP_TITLE}"),
|
||||||
'email_user_notification_subject' => $db->getSetting('email_user_notification_subject', '{APP_TITLE} - Berechtigungen geändert'),
|
'email_user_notification_subject' => $db->getSetting('email_user_notification_subject', '{APP_TITLE} - Berechtigungen geändert'),
|
||||||
'email_user_notification_body' => $db->getSetting('email_user_notification_body', "Hallo {USER_NAME},\n\n{CHANGES}"),
|
'email_user_notification_body' => $db->getSetting('email_user_notification_body', "Hallo {USER_NAME},\n\n{CHANGES}"),
|
||||||
'print_template' => $db->getSetting('print_template', '<div style="text-align:center;padding:40px"><h1>{APP_TITLE}</h1><h2>WLAN Code</h2><div style="font-size:48px;font-weight:bold;margin:30px 0;font-family:monospace">{VOUCHER_CODE}</div><p><strong>Gültig bis:</strong> {EXPIRY_DATE} {EXPIRY_TIME}</p><p><strong>Site:</strong> {SITE_NAME}</p><p><strong>Geräte:</strong> {MAX_USES}</p><hr style="margin:30px 0"><div>{INSTRUCTIONS}</div></div>'),
|
'print_template' => $db->getSetting('print_template', Ui::defaultPrintTemplate()),
|
||||||
'brand_accent' => $db->getSetting('brand_accent', '') ?: Ui::DEFAULT_ACCENT,
|
|
||||||
'brand_accent_dark' => $db->getSetting('brand_accent_dark', '') ?: Ui::DEFAULT_ACCENT_DARK,
|
|
||||||
'brand_gradient_from' => $db->getSetting('brand_gradient_from', '') ?: Ui::DEFAULT_GRADIENT_FROM,
|
|
||||||
'brand_gradient_to' => $db->getSetting('brand_gradient_to', '') ?: Ui::DEFAULT_GRADIENT_TO,
|
|
||||||
'brand_radius' => $db->getSetting('brand_radius', (string)Ui::DEFAULT_RADIUS),
|
|
||||||
'login_panel_enabled' => $db->getSetting('login_panel_enabled', '1'),
|
|
||||||
'login_brand_name' => $db->getSetting('login_brand_name', ''),
|
|
||||||
'login_logo_url' => $db->getSetting('login_logo_url', ''),
|
|
||||||
'login_claim_title' => $db->getSetting('login_claim_title', ''),
|
|
||||||
'login_claim_text' => $db->getSetting('login_claim_text', ''),
|
|
||||||
'login_features' => $db->getSetting('login_features', ''),
|
|
||||||
'login_footer' => $db->getSetting('login_footer', ''),
|
|
||||||
'login_bg_image' => $db->getSetting('login_bg_image', ''),
|
|
||||||
'login_bg_from' => $db->getSetting('login_bg_from', '#3b2f8f'),
|
|
||||||
'login_bg_to' => $db->getSetting('login_bg_to', '#6d5ce7'),
|
|
||||||
'login_bg_overlay' => $db->getSetting('login_bg_overlay', '40'),
|
|
||||||
'cron_token' => $db->getSetting('cron_token', ''),
|
'cron_token' => $db->getSetting('cron_token', ''),
|
||||||
'last_cron_sync' => $db->getSetting('last_cron_sync', ''),
|
'last_cron_sync' => $db->getSetting('last_cron_sync', ''),
|
||||||
];
|
];
|
||||||
|
|
@ -644,12 +628,12 @@ $adminBase = '';
|
||||||
<div class="form-group"><label>System-URL</label><input type="url" name="system_url" value="<?= htmlspecialchars($cs['system_url']) ?>"><div class="help-text">Auto: <code><?= $autoDetectedUrl ?></code></div></div>
|
<div class="form-group"><label>System-URL</label><input type="url" name="system_url" value="<?= htmlspecialchars($cs['system_url']) ?>"><div class="help-text">Auto: <code><?= $autoDetectedUrl ?></code></div></div>
|
||||||
<hr class="section-divider">
|
<hr class="section-divider">
|
||||||
<h3 style="margin-bottom:15px; color: var(--text-primary);"><?= __('settings_tpl_voucher_mail') ?></h3>
|
<h3 style="margin-bottom:15px; color: var(--text-primary);"><?= __('settings_tpl_voucher_mail') ?></h3>
|
||||||
<div class="placeholder-info"><h4>Platzhalter:</h4><div class="placeholder-list"><code>{VOUCHER_CODE}</code><code>{SITE_NAME}</code><code>{MAX_USES}</code><code>{APP_TITLE}</code><code>{INSTRUCTIONS}</code></div></div>
|
<div class="placeholder-info"><h4><?= __('settings_placeholders') ?></h4><div class="placeholder-list"><code>{VOUCHER_CARD}</code><code>{VOUCHER_CODE}</code><code>{SITE_NAME}</code><code>{MAX_USES}</code><code>{APP_TITLE}</code><code>{INSTRUCTIONS}</code></div><p class="help-text"><?= __('settings_card_hint') ?></p></div>
|
||||||
<div class="form-group"><label>Betreff</label><input type="text" name="email_voucher_subject" value="<?= htmlspecialchars($cs['email_voucher_subject']) ?>"></div>
|
<div class="form-group"><label>Betreff</label><input type="text" name="email_voucher_subject" value="<?= htmlspecialchars($cs['email_voucher_subject']) ?>"></div>
|
||||||
<div class="form-group"><label>E-Mail Text</label><textarea name="email_voucher_body" class="tinymce-editor"><?= htmlspecialchars($cs['email_voucher_body']) ?></textarea></div>
|
<div class="form-group"><label>E-Mail Text</label><textarea name="email_voucher_body" class="tinymce-editor"><?= htmlspecialchars($cs['email_voucher_body']) ?></textarea></div>
|
||||||
<hr class="section-divider">
|
<hr class="section-divider">
|
||||||
<h3 style="margin-bottom:15px; color: var(--text-primary);"><?= __('settings_tpl_user_notify') ?></h3>
|
<h3 style="margin-bottom:15px; color: var(--text-primary);"><?= __('settings_tpl_user_notify') ?></h3>
|
||||||
<div class="placeholder-info"><h4>Platzhalter:</h4><div class="placeholder-list"><code>{USER_NAME}</code><code>{CHANGES}</code><code>{APP_TITLE}</code><code>{SYSTEM_URL}</code></div></div>
|
<div class="placeholder-info"><h4><?= __('settings_placeholders') ?></h4><div class="placeholder-list"><code>{USER_NAME}</code><code>{CHANGES}</code><code>{APP_TITLE}</code><code>{SYSTEM_URL}</code></div></div>
|
||||||
<div class="form-group"><label>Betreff</label><input type="text" name="email_user_notification_subject" value="<?= htmlspecialchars($cs['email_user_notification_subject']) ?>"></div>
|
<div class="form-group"><label>Betreff</label><input type="text" name="email_user_notification_subject" value="<?= htmlspecialchars($cs['email_user_notification_subject']) ?>"></div>
|
||||||
<div class="form-group"><label>E-Mail Text</label><textarea name="email_user_notification_body" class="tinymce-editor"><?= htmlspecialchars($cs['email_user_notification_body']) ?></textarea></div>
|
<div class="form-group"><label>E-Mail Text</label><textarea name="email_user_notification_body" class="tinymce-editor"><?= htmlspecialchars($cs['email_user_notification_body']) ?></textarea></div>
|
||||||
<button type="submit" name="save_settings" class="btn btn-primary"><i class="fas fa-save" aria-hidden="true"></i> <?= __('btn_save') ?></button>
|
<button type="submit" name="save_settings" class="btn btn-primary"><i class="fas fa-save" aria-hidden="true"></i> <?= __('btn_save') ?></button>
|
||||||
|
|
@ -669,7 +653,7 @@ $adminBase = '';
|
||||||
|
|
||||||
<hr class="section-divider">
|
<hr class="section-divider">
|
||||||
<h3 style="margin-bottom:15px; color: var(--text-primary);">Druck-Template</h3>
|
<h3 style="margin-bottom:15px; color: var(--text-primary);">Druck-Template</h3>
|
||||||
<div class="placeholder-info"><h4>Platzhalter:</h4><div class="placeholder-list"><code>{VOUCHER_CODE}</code><code>{EXPIRY_DATE}</code><code>{EXPIRY_TIME}</code><code>{SITE_NAME}</code><code>{MAX_USES}</code><code>{APP_TITLE}</code><code>{INSTRUCTIONS}</code></div></div>
|
<div class="placeholder-info"><h4><?= __('settings_placeholders') ?></h4><div class="placeholder-list"><code>{QR_CODE}</code><code>{VOUCHER_CODE}</code><code>{EXPIRY_DATE}</code><code>{EXPIRY_TIME}</code><code>{SITE_NAME}</code><code>{MAX_USES}</code><code>{APP_TITLE}</code><code>{INSTRUCTIONS}</code></div><p class="help-text"><?= __('settings_qr_hint') ?></p></div>
|
||||||
<div class="form-group"><label><?= __('settings_print_template') ?></label><textarea name="print_template" class="tinymce-editor" style="min-height:250px;"><?= htmlspecialchars($cs['print_template']) ?></textarea></div>
|
<div class="form-group"><label><?= __('settings_print_template') ?></label><textarea name="print_template" class="tinymce-editor" style="min-height:250px;"><?= htmlspecialchars($cs['print_template']) ?></textarea></div>
|
||||||
<button type="submit" name="save_settings" class="btn btn-primary"><i class="fas fa-save" aria-hidden="true"></i> <?= __('btn_save') ?></button>
|
<button type="submit" name="save_settings" class="btn btn-primary"><i class="fas fa-save" aria-hidden="true"></i> <?= __('btn_save') ?></button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -1531,6 +1531,10 @@ input.search-bar, .site-selector .search-bar { min-width: 240px; width: auto; fl
|
||||||
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
|
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
|
||||||
@media (max-width: 720px) { .row, .row3 { grid-template-columns: 1fr; } }
|
@media (max-width: 720px) { .row, .row3 { grid-template-columns: 1fr; } }
|
||||||
|
|
||||||
|
/* QR-Code auf der Druckkarte */
|
||||||
|
.print-qr { display: flex; justify-content: center; line-height: 0; }
|
||||||
|
.print-qr img, .print-qr canvas { display: block; }
|
||||||
|
|
||||||
/* Sprungmarke zum Inhalt (nur bei Tastaturfokus sichtbar) */
|
/* Sprungmarke zum Inhalt (nur bei Tastaturfokus sichtbar) */
|
||||||
.skip-link {
|
.skip-link {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
||||||
|
|
@ -1,265 +1,339 @@
|
||||||
<?php
|
<?php
|
||||||
class Mailer {
|
class Mailer {
|
||||||
private $db;
|
private $db;
|
||||||
private $smtpEnabled;
|
private $smtpEnabled;
|
||||||
private $smtpHost;
|
private $smtpHost;
|
||||||
private $smtpPort;
|
private $smtpPort;
|
||||||
private $smtpUsername;
|
private $smtpUsername;
|
||||||
private $smtpPassword;
|
private $smtpPassword;
|
||||||
private $smtpEncryption;
|
private $smtpEncryption;
|
||||||
private $fromEmail;
|
private $fromEmail;
|
||||||
private $fromName;
|
private $fromName;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = Database::getInstance();
|
$this->db = Database::getInstance();
|
||||||
$this->loadSettings();
|
$this->loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadSettings() {
|
private function loadSettings() {
|
||||||
$this->smtpEnabled = $this->db->getSetting('smtp_enabled', '0') === '1';
|
$this->smtpEnabled = $this->db->getSetting('smtp_enabled', '0') === '1';
|
||||||
$this->smtpHost = $this->db->getSetting('smtp_host', '');
|
$this->smtpHost = $this->db->getSetting('smtp_host', '');
|
||||||
$this->smtpPort = (int)$this->db->getSetting('smtp_port', '587');
|
$this->smtpPort = (int)$this->db->getSetting('smtp_port', '587');
|
||||||
$this->smtpUsername = $this->db->getSetting('smtp_username', '');
|
$this->smtpUsername = $this->db->getSetting('smtp_username', '');
|
||||||
$this->smtpPassword = $this->db->getSetting('smtp_password', '');
|
$this->smtpPassword = $this->db->getSetting('smtp_password', '');
|
||||||
$this->smtpEncryption = $this->db->getSetting('smtp_encryption', 'tls');
|
$this->smtpEncryption = $this->db->getSetting('smtp_encryption', 'tls');
|
||||||
$this->fromEmail = $this->db->getSetting('smtp_from_email', 'noreply@' . $_SERVER['HTTP_HOST']);
|
$this->fromEmail = $this->db->getSetting('smtp_from_email', 'noreply@' . $_SERVER['HTTP_HOST']);
|
||||||
$this->fromName = $this->db->getSetting('smtp_from_name', $this->db->getSetting('app_title', 'UniFi Voucher System'));
|
$this->fromName = $this->db->getSetting('smtp_from_name', $this->db->getSetting('app_title', 'UniFi Voucher System'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendRaw($to, $subject, $plainBody) {
|
public function sendRaw($to, $subject, $plainBody) {
|
||||||
return $this->send($to, $subject, $plainBody, false);
|
return $this->send($to, $subject, $plainBody, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function send($to, $subject, $body, $isHtml = false) {
|
public function send($to, $subject, $body, $isHtml = false) {
|
||||||
// Bis zu 2 Versuche bei vorübergehenden Zustellfehlern (Retry).
|
// Bis zu 2 Versuche bei vorübergehenden Zustellfehlern (Retry).
|
||||||
$attempts = 2;
|
$attempts = 2;
|
||||||
for ($i = 1; $i <= $attempts; $i++) {
|
for ($i = 1; $i <= $attempts; $i++) {
|
||||||
if (!$this->smtpEnabled || empty($this->smtpHost)) {
|
if (!$this->smtpEnabled || empty($this->smtpHost)) {
|
||||||
$ok = $this->sendWithPhpMail($to, $subject, $body);
|
$ok = $this->sendWithPhpMail($to, $subject, $body);
|
||||||
} else {
|
} else {
|
||||||
$ok = $this->sendWithSmtp($to, $subject, $body, $isHtml);
|
$ok = $this->sendWithSmtp($to, $subject, $body, $isHtml);
|
||||||
}
|
}
|
||||||
if ($ok) {
|
if ($ok) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ($i < $attempts) {
|
if ($i < $attempts) {
|
||||||
usleep(500000); // 0,5s vor erneutem Versuch
|
usleep(500000); // 0,5s vor erneutem Versuch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error_log("Mailer: Zustellung an {$to} nach {$attempts} Versuchen fehlgeschlagen.");
|
error_log("Mailer: Zustellung an {$to} nach {$attempts} Versuchen fehlgeschlagen.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sendWithPhpMail($to, $subject, $body) {
|
private function sendWithPhpMail($to, $subject, $body) {
|
||||||
$headers = "From: {$this->fromName} <{$this->fromEmail}>\r\n";
|
$headers = "From: {$this->fromName} <{$this->fromEmail}>\r\n";
|
||||||
$headers .= "Reply-To: {$this->fromEmail}\r\n";
|
$headers .= "Reply-To: {$this->fromEmail}\r\n";
|
||||||
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
|
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
|
||||||
|
|
||||||
return mail($to, $subject, $body, $headers);
|
return mail($to, $subject, $body, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sendWithSmtp($to, $subject, $body, $isHtml = false) {
|
private function sendWithSmtp($to, $subject, $body, $isHtml = false) {
|
||||||
try {
|
try {
|
||||||
// Verbindung aufbauen
|
// Verbindung aufbauen
|
||||||
$socket = $this->connectToSmtp();
|
$socket = $this->connectToSmtp();
|
||||||
|
|
||||||
// EHLO
|
// EHLO
|
||||||
$this->smtpCommand($socket, "EHLO " . $_SERVER['HTTP_HOST']);
|
$this->smtpCommand($socket, "EHLO " . $_SERVER['HTTP_HOST']);
|
||||||
|
|
||||||
// STARTTLS wenn nötig
|
// STARTTLS wenn nötig
|
||||||
if ($this->smtpEncryption === 'tls') {
|
if ($this->smtpEncryption === 'tls') {
|
||||||
$this->smtpCommand($socket, "STARTTLS");
|
$this->smtpCommand($socket, "STARTTLS");
|
||||||
stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
|
stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
|
||||||
$this->smtpCommand($socket, "EHLO " . $_SERVER['HTTP_HOST']);
|
$this->smtpCommand($socket, "EHLO " . $_SERVER['HTTP_HOST']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AUTH LOGIN
|
// AUTH LOGIN
|
||||||
$this->smtpCommand($socket, "AUTH LOGIN");
|
$this->smtpCommand($socket, "AUTH LOGIN");
|
||||||
$this->smtpCommand($socket, base64_encode($this->smtpUsername));
|
$this->smtpCommand($socket, base64_encode($this->smtpUsername));
|
||||||
$this->smtpCommand($socket, base64_encode($this->smtpPassword));
|
$this->smtpCommand($socket, base64_encode($this->smtpPassword));
|
||||||
|
|
||||||
// MAIL FROM
|
// MAIL FROM
|
||||||
$this->smtpCommand($socket, "MAIL FROM:<{$this->fromEmail}>");
|
$this->smtpCommand($socket, "MAIL FROM:<{$this->fromEmail}>");
|
||||||
|
|
||||||
// RCPT TO
|
// RCPT TO
|
||||||
$this->smtpCommand($socket, "RCPT TO:<{$to}>");
|
$this->smtpCommand($socket, "RCPT TO:<{$to}>");
|
||||||
|
|
||||||
// DATA
|
// DATA
|
||||||
$this->smtpCommand($socket, "DATA");
|
$this->smtpCommand($socket, "DATA");
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
$message = "From: {$this->fromName} <{$this->fromEmail}>\r\n";
|
$message = "From: {$this->fromName} <{$this->fromEmail}>\r\n";
|
||||||
$message .= "To: {$to}\r\n";
|
$message .= "To: {$to}\r\n";
|
||||||
$message .= "Subject: =?UTF-8?B?" . base64_encode($subject) . "?=\r\n";
|
$message .= "Subject: =?UTF-8?B?" . base64_encode($subject) . "?=\r\n";
|
||||||
$message .= "MIME-Version: 1.0\r\n";
|
$message .= "MIME-Version: 1.0\r\n";
|
||||||
|
|
||||||
if ($isHtml) {
|
if ($isHtml) {
|
||||||
$message .= "Content-Type: text/html; charset=UTF-8\r\n";
|
$message .= "Content-Type: text/html; charset=UTF-8\r\n";
|
||||||
} else {
|
} else {
|
||||||
$message .= "Content-Type: text/plain; charset=UTF-8\r\n";
|
$message .= "Content-Type: text/plain; charset=UTF-8\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$message .= "\r\n";
|
$message .= "\r\n";
|
||||||
|
|
||||||
// Body - bei Plain Text Zeilenumbrüche konvertieren
|
// Body - bei Plain Text Zeilenumbrüche konvertieren
|
||||||
if (!$isHtml) {
|
if (!$isHtml) {
|
||||||
$body = nl2br($body, false); // Für Plain Text
|
$body = nl2br($body, false); // Für Plain Text
|
||||||
$body = str_replace('<br>', "\r\n", $body);
|
$body = str_replace('<br>', "\r\n", $body);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message .= $body;
|
$message .= $body;
|
||||||
$message .= "\r\n.\r\n";
|
$message .= "\r\n.\r\n";
|
||||||
|
|
||||||
fwrite($socket, $message);
|
fwrite($socket, $message);
|
||||||
$response = fgets($socket);
|
$response = fgets($socket);
|
||||||
|
|
||||||
// QUIT
|
// QUIT
|
||||||
$this->smtpCommand($socket, "QUIT");
|
$this->smtpCommand($socket, "QUIT");
|
||||||
fclose($socket);
|
fclose($socket);
|
||||||
|
|
||||||
return strpos($response, '250') === 0;
|
return strpos($response, '250') === 0;
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
error_log("SMTP Error: " . $e->getMessage());
|
error_log("SMTP Error: " . $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function connectToSmtp() {
|
private function connectToSmtp() {
|
||||||
$context = stream_context_create([
|
$context = stream_context_create([
|
||||||
'ssl' => [
|
'ssl' => [
|
||||||
'verify_peer' => false,
|
'verify_peer' => false,
|
||||||
'verify_peer_name' => false,
|
'verify_peer_name' => false,
|
||||||
'allow_self_signed' => true
|
'allow_self_signed' => true
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($this->smtpEncryption === 'ssl') {
|
if ($this->smtpEncryption === 'ssl') {
|
||||||
$host = 'ssl://' . $this->smtpHost;
|
$host = 'ssl://' . $this->smtpHost;
|
||||||
} else {
|
} else {
|
||||||
$host = $this->smtpHost;
|
$host = $this->smtpHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
$socket = stream_socket_client(
|
$socket = stream_socket_client(
|
||||||
$host . ':' . $this->smtpPort,
|
$host . ':' . $this->smtpPort,
|
||||||
$errno,
|
$errno,
|
||||||
$errstr,
|
$errstr,
|
||||||
30,
|
30,
|
||||||
STREAM_CLIENT_CONNECT,
|
STREAM_CLIENT_CONNECT,
|
||||||
$context
|
$context
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$socket) {
|
if (!$socket) {
|
||||||
throw new Exception("SMTP Connection failed: $errstr ($errno)");
|
throw new Exception("SMTP Connection failed: $errstr ($errno)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Willkommensnachricht lesen
|
// Willkommensnachricht lesen
|
||||||
fgets($socket);
|
fgets($socket);
|
||||||
|
|
||||||
return $socket;
|
return $socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function smtpCommand($socket, $command) {
|
private function smtpCommand($socket, $command) {
|
||||||
fwrite($socket, $command . "\r\n");
|
fwrite($socket, $command . "\r\n");
|
||||||
$response = fgets($socket);
|
$response = fgets($socket);
|
||||||
|
|
||||||
// Prüfen auf Fehler (4xx oder 5xx)
|
// Prüfen auf Fehler (4xx oder 5xx)
|
||||||
if (preg_match('/^[45]/', $response)) {
|
if (preg_match('/^[45]/', $response)) {
|
||||||
throw new Exception("SMTP Error: $response");
|
throw new Exception("SMTP Error: $response");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vordefinierte E-Mail-Templates
|
// Vordefinierte E-Mail-Templates
|
||||||
public function sendVoucherEmail($to, $voucherCode, $siteName, $maxUses) {
|
/**
|
||||||
$appTitle = $this->db->getSetting('app_title', 'UniFi Voucher System');
|
* Legt den Nachrichtentext in ein schlichtes, markentreues HTML-Gerüst.
|
||||||
$instructionHeader = $this->db->getSetting('instruction_header', '');
|
* Bewusst Tabellen + Inline-Styles: nur so rendern Outlook & Co. zuverlässig.
|
||||||
$instructionText = $this->db->getSetting('instruction_text', '');
|
*/
|
||||||
|
private function brandedHtml(string $title, string $contentHtml, string $footerNote = ''): string
|
||||||
// System-URL aus Einstellungen oder automatisch erkennen
|
{
|
||||||
$systemUrl = $this->db->getSetting('system_url', '');
|
$accent = $this->db->getSetting('brand_gradient_from', '') ?: '#5b5bd6';
|
||||||
if (empty($systemUrl)) {
|
$accent2 = $this->db->getSetting('brand_gradient_to', '') ?: '#8b5cf6';
|
||||||
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
|
if (!preg_match('/^#[0-9a-fA-F]{6}$/', $accent)) { $accent = '#5b5bd6'; }
|
||||||
$host = $_SERVER['HTTP_HOST'];
|
if (!preg_match('/^#[0-9a-fA-F]{6}$/', $accent2)) { $accent2 = '#8b5cf6'; }
|
||||||
$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
|
|
||||||
$scriptPath = $scriptPath === '/' ? '' : $scriptPath;
|
$safeTitle = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
|
||||||
$systemUrl = $protocol . '://' . $host . $scriptPath;
|
$year = date('Y');
|
||||||
}
|
$footer = $footerNote !== '' ? '<div style="margin-top:8px;">' . htmlspecialchars($footerNote, ENT_QUOTES, 'UTF-8') . '</div>' : '';
|
||||||
|
|
||||||
// Template aus Datenbank laden
|
return '<!DOCTYPE html><html><head><meta charset="UTF-8">'
|
||||||
$subjectTemplate = $this->db->getSetting('email_voucher_subject', '{APP_TITLE} - Ihr WLAN-Zugang');
|
. '<meta name="viewport" content="width=device-width, initial-scale=1.0">'
|
||||||
$bodyTemplate = $this->db->getSetting('email_voucher_body', "Hallo,\n\nIhr WLAN-Zugangscode lautet:\n\n<strong>{VOUCHER_CODE}</strong>\n\nGültigkeit: 8 Stunden ab Erstellung\nMaximale Geräte: {MAX_USES}\nStandort: {SITE_NAME}\n\n{INSTRUCTIONS}\n\nMit freundlichen Grüßen\n{APP_TITLE}");
|
. '<title>' . $safeTitle . '</title></head>'
|
||||||
|
. '<body style="margin:0;padding:0;background:#f6f7f9;">'
|
||||||
// Anleitung formatieren
|
. '<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="background:#f6f7f9;padding:28px 12px;">'
|
||||||
$instructions = '';
|
. '<tr><td align="center">'
|
||||||
if ($instructionText) {
|
. '<table role="presentation" width="600" cellpadding="0" cellspacing="0" style="max-width:600px;width:100%;background:#ffffff;border:1px solid #e5e8ee;border-radius:14px;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,\'Segoe UI\',Roboto,Helvetica,Arial,sans-serif;">'
|
||||||
$instructions = $instructionHeader . "\n" . $instructionText;
|
. '<tr><td style="background:' . $accent . ';background-image:linear-gradient(135deg,' . $accent . ' 0%,' . $accent2 . ' 100%);padding:22px 26px;">'
|
||||||
}
|
. '<div style="color:#ffffff;font-size:16px;font-weight:600;letter-spacing:-0.01em;">' . $safeTitle . '</div>'
|
||||||
|
. '</td></tr>'
|
||||||
// Platzhalter ersetzen
|
. '<tr><td style="padding:26px;color:#101625;font-size:15px;line-height:1.6;">' . $contentHtml . '</td></tr>'
|
||||||
$placeholders = [
|
. '<tr><td style="padding:16px 26px;background:#f8f9fb;border-top:1px solid #e5e8ee;color:#6b7280;font-size:12px;">'
|
||||||
'{VOUCHER_CODE}' => $voucherCode,
|
. '© ' . $year . ' ' . $safeTitle . $footer
|
||||||
'{SITE_NAME}' => $siteName,
|
. '</td></tr>'
|
||||||
'{MAX_USES}' => $maxUses,
|
. '</table></td></tr></table></body></html>';
|
||||||
'{APP_TITLE}' => $appTitle,
|
}
|
||||||
'{INSTRUCTIONS}' => $instructions,
|
|
||||||
'{SYSTEM_URL}' => $systemUrl
|
/**
|
||||||
];
|
* Voucher-Code als hervorgehobene Karte für die E-Mail.
|
||||||
|
*/
|
||||||
$subject = str_replace(array_keys($placeholders), array_values($placeholders), $subjectTemplate);
|
private function voucherCardHtml(string $code, string $siteName, $maxUses): string
|
||||||
$body = str_replace(array_keys($placeholders), array_values($placeholders), $bodyTemplate);
|
{
|
||||||
|
return '<table role="presentation" width="100%" cellpadding="0" cellspacing="0" '
|
||||||
// HTML oder Plain Text prüfen
|
. 'style="margin:18px 0;background:#f8f9fb;border:1px solid #e5e8ee;border-radius:12px;">'
|
||||||
$isHtml = strip_tags($body) !== $body;
|
. '<tr><td align="center" style="padding:22px;">'
|
||||||
|
. '<div style="font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:#6b7280;">'
|
||||||
return $this->send($to, $subject, $body, $isHtml);
|
. htmlspecialchars($siteName, ENT_QUOTES, 'UTF-8') . '</div>'
|
||||||
}
|
. '<div style="margin:10px 0;font-family:Consolas,Menlo,monospace;font-size:28px;font-weight:700;letter-spacing:.12em;color:#101625;">'
|
||||||
|
. htmlspecialchars($code, ENT_QUOTES, 'UTF-8') . '</div>'
|
||||||
public function sendTestEmail($to) {
|
. '<div style="font-size:13px;color:#525c6e;">'
|
||||||
$appTitle = $this->db->getSetting('app_title', 'UniFi Voucher System');
|
. htmlspecialchars((string)$maxUses, ENT_QUOTES, 'UTF-8') . ' '
|
||||||
$subject = '[Test] E-Mail-Konfiguration – ' . $appTitle;
|
. htmlspecialchars(function_exists('__') ? __('label_devices') : 'Geräte', ENT_QUOTES, 'UTF-8') . '</div>'
|
||||||
$body = "Dies ist eine Test-E-Mail von {$appTitle}.\n\nDie SMTP-Konfiguration ist korrekt eingerichtet.";
|
. '</td></tr></table>';
|
||||||
return $this->send($to, $subject, $body, false);
|
}
|
||||||
}
|
|
||||||
|
public function sendVoucherEmail($to, $voucherCode, $siteName, $maxUses) {
|
||||||
public function sendUserNotification($to, $userName, $changes) {
|
$appTitle = $this->db->getSetting('app_title', 'UniFi Voucher System');
|
||||||
$appTitle = $this->db->getSetting('app_title', 'UniFi Voucher System');
|
$instructionHeader = $this->db->getSetting('instruction_header', '');
|
||||||
|
$instructionText = $this->db->getSetting('instruction_text', '');
|
||||||
// System-URL aus Einstellungen oder automatisch erkennen
|
|
||||||
$systemUrl = $this->db->getSetting('system_url', '');
|
// System-URL aus Einstellungen oder automatisch erkennen
|
||||||
if (empty($systemUrl)) {
|
$systemUrl = $this->db->getSetting('system_url', '');
|
||||||
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
|
if (empty($systemUrl)) {
|
||||||
$host = $_SERVER['HTTP_HOST'];
|
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
|
||||||
$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
$scriptPath = $scriptPath === '/' ? '' : $scriptPath;
|
$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
|
||||||
$systemUrl = $protocol . '://' . $host . $scriptPath;
|
$scriptPath = $scriptPath === '/' ? '' : $scriptPath;
|
||||||
}
|
$systemUrl = $protocol . '://' . $host . $scriptPath;
|
||||||
|
}
|
||||||
// Template aus Datenbank laden
|
|
||||||
$subjectTemplate = $this->db->getSetting('email_user_notification_subject', '{APP_TITLE} - Ihre Berechtigungen wurden geändert');
|
// Template aus Datenbank laden
|
||||||
$bodyTemplate = $this->db->getSetting('email_user_notification_body', "Hallo {USER_NAME},\n\nEin Administrator hat Ihre Berechtigungen im {APP_TITLE} geändert:\n\n{CHANGES}\n\nSie können sich unter folgender Adresse anmelden:\n{SYSTEM_URL}\n\nMit freundlichen Grüßen\n{APP_TITLE}");
|
$subjectTemplate = $this->db->getSetting('email_voucher_subject', '{APP_TITLE} - Ihr WLAN-Zugang');
|
||||||
|
$bodyTemplate = $this->db->getSetting('email_voucher_body', "Hallo,\n\nhier ist Ihr WLAN-Zugangscode:\n{VOUCHER_CARD}\n<strong>Maximale Geräte:</strong> {MAX_USES}<br>\n<strong>Standort:</strong> {SITE_NAME}\n\n{INSTRUCTIONS}\n\nViele Grüße\n{APP_TITLE}");
|
||||||
// Änderungen formatieren
|
|
||||||
$changesText = '';
|
// Anleitung formatieren
|
||||||
foreach ($changes as $change) {
|
$instructions = '';
|
||||||
$changesText .= "• $change\n";
|
if ($instructionText) {
|
||||||
}
|
$instructions = $instructionHeader . "\n" . $instructionText;
|
||||||
|
}
|
||||||
// Platzhalter ersetzen
|
|
||||||
$placeholders = [
|
// Platzhalter ersetzen
|
||||||
'{USER_NAME}' => $userName,
|
$placeholders = [
|
||||||
'{CHANGES}' => $changesText,
|
'{VOUCHER_CARD}' => $this->voucherCardHtml($voucherCode, (string)$siteName, $maxUses),
|
||||||
'{APP_TITLE}' => $appTitle,
|
'{VOUCHER_CODE}' => $voucherCode,
|
||||||
'{SYSTEM_URL}' => $systemUrl
|
'{SITE_NAME}' => $siteName,
|
||||||
];
|
'{MAX_USES}' => $maxUses,
|
||||||
|
'{APP_TITLE}' => $appTitle,
|
||||||
$subject = str_replace(array_keys($placeholders), array_values($placeholders), $subjectTemplate);
|
'{INSTRUCTIONS}' => $instructions,
|
||||||
$body = str_replace(array_keys($placeholders), array_values($placeholders), $bodyTemplate);
|
'{SYSTEM_URL}' => $systemUrl
|
||||||
|
];
|
||||||
// HTML oder Plain Text prüfen
|
|
||||||
$isHtml = strip_tags($body) !== $body;
|
$subject = str_replace(array_keys($placeholders), array_values($placeholders), $subjectTemplate);
|
||||||
|
|
||||||
return $this->send($to, $subject, $body, $isHtml);
|
// Umbrueche der Vorlage vor dem Einsetzen der Platzhalter umwandeln,
|
||||||
}
|
// sonst wuerde das Markup der Voucher-Karte die Erkennung stoeren.
|
||||||
|
$isHtml = strip_tags($bodyTemplate) !== $bodyTemplate || strpos($bodyTemplate, '{VOUCHER_CARD}') !== false;
|
||||||
|
$template = $isHtml ? $this->textToHtml($bodyTemplate) : $bodyTemplate;
|
||||||
|
$body = str_replace(array_keys($placeholders), array_values($placeholders), $template);
|
||||||
|
|
||||||
|
if ($isHtml) {
|
||||||
|
$body = $this->brandedHtml($appTitle, $body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->send($to, $subject, $body, $isHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendTestEmail($to) {
|
||||||
|
$appTitle = $this->db->getSetting('app_title', 'UniFi Voucher System');
|
||||||
|
$subject = '[Test] E-Mail-Konfiguration – ' . $appTitle;
|
||||||
|
$body = "Dies ist eine Test-E-Mail von {$appTitle}.\n\nDie SMTP-Konfiguration ist korrekt eingerichtet.";
|
||||||
|
return $this->send($to, $subject, $body, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sendUserNotification($to, $userName, $changes) {
|
||||||
|
$appTitle = $this->db->getSetting('app_title', 'UniFi Voucher System');
|
||||||
|
|
||||||
|
// System-URL aus Einstellungen oder automatisch erkennen
|
||||||
|
$systemUrl = $this->db->getSetting('system_url', '');
|
||||||
|
if (empty($systemUrl)) {
|
||||||
|
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
|
||||||
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
|
$scriptPath = dirname($_SERVER['SCRIPT_NAME']);
|
||||||
|
$scriptPath = $scriptPath === '/' ? '' : $scriptPath;
|
||||||
|
$systemUrl = $protocol . '://' . $host . $scriptPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Template aus Datenbank laden
|
||||||
|
$subjectTemplate = $this->db->getSetting('email_user_notification_subject', '{APP_TITLE} - Ihre Berechtigungen wurden geändert');
|
||||||
|
$bodyTemplate = $this->db->getSetting('email_user_notification_body', "Hallo {USER_NAME},\n\nEin Administrator hat Ihre Berechtigungen im {APP_TITLE} geändert:\n\n{CHANGES}\n\nSie können sich unter folgender Adresse anmelden:\n{SYSTEM_URL}\n\nMit freundlichen Grüßen\n{APP_TITLE}");
|
||||||
|
|
||||||
|
// Änderungen formatieren
|
||||||
|
$changesText = '';
|
||||||
|
foreach ($changes as $change) {
|
||||||
|
$changesText .= "• $change\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Platzhalter ersetzen
|
||||||
|
$placeholders = [
|
||||||
|
'{USER_NAME}' => $userName,
|
||||||
|
'{CHANGES}' => $changesText,
|
||||||
|
'{APP_TITLE}' => $appTitle,
|
||||||
|
'{SYSTEM_URL}' => $systemUrl
|
||||||
|
];
|
||||||
|
|
||||||
|
$subject = str_replace(array_keys($placeholders), array_values($placeholders), $subjectTemplate);
|
||||||
|
|
||||||
|
$isHtml = strip_tags($bodyTemplate) !== $bodyTemplate;
|
||||||
|
$template = $isHtml ? $this->textToHtml($bodyTemplate) : $bodyTemplate;
|
||||||
|
$body = str_replace(array_keys($placeholders), array_values($placeholders), $template);
|
||||||
|
|
||||||
|
if ($isHtml) {
|
||||||
|
$body = $this->brandedHtml($appTitle, $body);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->send($to, $subject, $body, $isHtml);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zeilenumbrüche aus dem Vorlagentext in HTML übernehmen, ohne bereits
|
||||||
|
* vorhandenes Markup (z. B. aus dem WYSIWYG-Editor) zu zerstören.
|
||||||
|
*/
|
||||||
|
private function textToHtml(string $body): string
|
||||||
|
{
|
||||||
|
if (preg_match('#<(p|div|ul|ol|h[1-6])[\s>]#i', $body)) {
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nl2br($body, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,6 +116,26 @@ class Ui
|
||||||
. '</style>';
|
. '</style>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard-Druckvorlage (wird nur verwendet, solange keine eigene
|
||||||
|
* Vorlage gespeichert ist). {QR_CODE} fuellt der Browser.
|
||||||
|
*/
|
||||||
|
public static function defaultPrintTemplate(): string
|
||||||
|
{
|
||||||
|
$validUntil = function_exists('__') ? __('print_valid_until') : 'Gültig bis';
|
||||||
|
$devices = function_exists('__') ? __('print_devices') : 'Geräte';
|
||||||
|
|
||||||
|
return '<div style="font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;'
|
||||||
|
. 'max-width:420px;margin:0 auto;padding:26px;border:1px dashed #9aa1ae;border-radius:14px;text-align:center;">'
|
||||||
|
. '<div style="font-size:13px;letter-spacing:.08em;text-transform:uppercase;color:#6b7280;">{APP_TITLE}</div>'
|
||||||
|
. '<div style="margin:6px 0 18px;font-size:15px;color:#101625;">{SITE_NAME}</div>'
|
||||||
|
. '{QR_CODE}'
|
||||||
|
. '<div style="margin:18px 0 6px;font-family:Consolas,Menlo,monospace;font-size:30px;font-weight:700;letter-spacing:.14em;color:#101625;">{VOUCHER_CODE}</div>'
|
||||||
|
. '<div style="font-size:13px;color:#525c6e;">' . $validUntil . ' {EXPIRY_DATE} {EXPIRY_TIME} · {MAX_USES} ' . $devices . '</div>'
|
||||||
|
. '<div style="margin-top:16px;padding-top:14px;border-top:1px solid #e5e8ee;font-size:12px;color:#525c6e;text-align:left;">{INSTRUCTIONS}</div>'
|
||||||
|
. '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL eines Bildes aus den Einstellungen.
|
* URL eines Bildes aus den Einstellungen.
|
||||||
* Hochgeladene Dateien liegen relativ zur Projektwurzel (uploads/…),
|
* Hochgeladene Dateien liegen relativ zur Projektwurzel (uploads/…),
|
||||||
|
|
|
||||||
28
index.php
28
index.php
|
|
@ -75,7 +75,7 @@ $instructionHeader = $db->getSetting('instruction_header', '');
|
||||||
$instructionText = $db->getSetting('instruction_text', '');
|
$instructionText = $db->getSetting('instruction_text', '');
|
||||||
$publicAccess = $db->getSetting('public_access', 0);
|
$publicAccess = $db->getSetting('public_access', 0);
|
||||||
$smtpEnabled = $db->getSetting('smtp_enabled', '0') === '1';
|
$smtpEnabled = $db->getSetting('smtp_enabled', '0') === '1';
|
||||||
$printTemplate = $db->getSetting('print_template', '<div style="text-align:center;padding:40px;font-family:sans-serif;"><h1>{APP_TITLE}</h1><h2>WLAN Zugangscode</h2><div style="font-size:48px;font-weight:bold;margin:30px 0;font-family:monospace;letter-spacing:4px;">{VOUCHER_CODE}</div><p><strong>Gültig bis:</strong> {EXPIRY_DATE} {EXPIRY_TIME}</p><p><strong>Standort:</strong> {SITE_NAME}</p><p><strong>Maximale Geräte:</strong> {MAX_USES}</p><hr style="margin:30px 0;"><div style="font-size:14px;text-align:left;">{INSTRUCTIONS}</div></div>');
|
$printTemplate = $db->getSetting('print_template', Ui::defaultPrintTemplate());
|
||||||
$defaultExpire = max(1, (int)$db->getSetting('default_expire_minutes', 480));
|
$defaultExpire = max(1, (int)$db->getSetting('default_expire_minutes', 480));
|
||||||
$defaultMaxUses = max(1, (int)$db->getSetting('default_max_uses', 1));
|
$defaultMaxUses = max(1, (int)$db->getSetting('default_max_uses', 1));
|
||||||
$maxUsesLimit = max(1, (int)$db->getSetting('max_uses_limit', 10));
|
$maxUsesLimit = max(1, (int)$db->getSetting('max_uses_limit', 10));
|
||||||
|
|
@ -272,9 +272,12 @@ function buildPrintCard($template, $data, $instructionHeader, $instructionText,
|
||||||
$instructions = $instructionHeader || $instructionText
|
$instructions = $instructionHeader || $instructionText
|
||||||
? htmlspecialchars($instructionHeader) . "\n" . $instructionText
|
? htmlspecialchars($instructionHeader) . "\n" . $instructionText
|
||||||
: '';
|
: '';
|
||||||
|
// {QR_CODE} wird erst im Browser gefuellt (siehe renderPrintQr()).
|
||||||
|
$qr = '<div class="print-qr" data-code="' . htmlspecialchars(str_replace('-', '', (string)$data['code']), ENT_QUOTES) . '"></div>';
|
||||||
|
|
||||||
return str_replace(
|
return str_replace(
|
||||||
['{VOUCHER_CODE}', '{SITE_NAME}', '{MAX_USES}', '{APP_TITLE}', '{INSTRUCTIONS}', '{EXPIRY_DATE}', '{EXPIRY_TIME}'],
|
['{QR_CODE}', '{VOUCHER_CODE}', '{SITE_NAME}', '{MAX_USES}', '{APP_TITLE}', '{INSTRUCTIONS}', '{EXPIRY_DATE}', '{EXPIRY_TIME}'],
|
||||||
[$data['code'], htmlspecialchars($data['site_name']), $data['max_uses'], htmlspecialchars($appTitle), $instructions, $data['expiry_date'], $data['expiry_time']],
|
[$qr, $data['code'], htmlspecialchars($data['site_name']), $data['max_uses'], htmlspecialchars($appTitle), $instructions, $data['expiry_date'], $data['expiry_time']],
|
||||||
$template
|
$template
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -289,7 +292,7 @@ function buildPrintCard($template, $data, $instructionHeader, $instructionText,
|
||||||
<?php if ($captchaMode === 'hcaptcha' && $hcaptchaSiteKey !== ''): ?>
|
<?php if ($captchaMode === 'hcaptcha' && $hcaptchaSiteKey !== ''): ?>
|
||||||
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
|
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($voucherCreated): ?>
|
<?php if ($voucherCreated || $bulkCreated): ?>
|
||||||
<?= Ui::script('assets/vendor/qrcodejs/qrcode.min.js') ?>
|
<?= Ui::script('assets/vendor/qrcodejs/qrcode.min.js') ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -635,6 +638,23 @@ function buildPrintCard($template, $data, $instructionHeader, $instructionText,
|
||||||
<div id="toast-container" role="status" aria-live="polite"></div>
|
<div id="toast-container" role="status" aria-live="polite"></div>
|
||||||
<script src="assets/global.js"></script>
|
<script src="assets/global.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
<?php if ($voucherCreated || $bulkCreated): ?>
|
||||||
|
// QR-Codes der Druckkarten erzeugen (im Browser, ohne externen Dienst)
|
||||||
|
function renderPrintQr() {
|
||||||
|
document.querySelectorAll('.print-qr').forEach(function (el) {
|
||||||
|
if (el.dataset.done) return;
|
||||||
|
el.dataset.done = '1';
|
||||||
|
new QRCode(el, {
|
||||||
|
text: el.dataset.code || '',
|
||||||
|
width: 132, height: 132,
|
||||||
|
colorDark: '#101625', colorLight: '#ffffff',
|
||||||
|
correctLevel: QRCode.CorrectLevel.M
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
document.addEventListener('DOMContentLoaded', renderPrintQr);
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($voucherCreated): ?>
|
<?php if ($voucherCreated): ?>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
new QRCode(document.getElementById('qrcode'), {
|
new QRCode(document.getElementById('qrcode'), {
|
||||||
|
|
|
||||||
|
|
@ -464,6 +464,11 @@ return [
|
||||||
'vouchers_resend' => 'Per E-Mail senden',
|
'vouchers_resend' => 'Per E-Mail senden',
|
||||||
'label_minutes_short' => 'Min.',
|
'label_minutes_short' => 'Min.',
|
||||||
'js_copy' => 'Kopieren',
|
'js_copy' => 'Kopieren',
|
||||||
|
'settings_placeholders' => 'Platzhalter:',
|
||||||
|
'settings_card_hint' => '{VOUCHER_CARD} rendert den Code als hervorgehobene Karte im Marken-Layout.',
|
||||||
|
'settings_qr_hint' => '{QR_CODE} fügt einen QR-Code mit dem Voucher-Code ein.',
|
||||||
|
'print_valid_until' => 'Gültig bis',
|
||||||
|
'print_devices' => 'Geräte',
|
||||||
'settings_tab_general' => 'Allgemein',
|
'settings_tab_general' => 'Allgemein',
|
||||||
'settings_tab_defaults' => 'Voucher-Standards',
|
'settings_tab_defaults' => 'Voucher-Standards',
|
||||||
'settings_tab_cron' => 'Cron-Sync',
|
'settings_tab_cron' => 'Cron-Sync',
|
||||||
|
|
|
||||||
|
|
@ -464,6 +464,11 @@ return [
|
||||||
'vouchers_resend' => 'Send by email',
|
'vouchers_resend' => 'Send by email',
|
||||||
'label_minutes_short' => 'min',
|
'label_minutes_short' => 'min',
|
||||||
'js_copy' => 'Copy',
|
'js_copy' => 'Copy',
|
||||||
|
'settings_placeholders' => 'Placeholders:',
|
||||||
|
'settings_card_hint' => '{VOUCHER_CARD} renders the code as a highlighted card in the branded layout.',
|
||||||
|
'settings_qr_hint' => '{QR_CODE} inserts a QR code containing the voucher code.',
|
||||||
|
'print_valid_until' => 'Valid until',
|
||||||
|
'print_devices' => 'devices',
|
||||||
'settings_tab_general' => 'General',
|
'settings_tab_general' => 'General',
|
||||||
'settings_tab_defaults' => 'Voucher Defaults',
|
'settings_tab_defaults' => 'Voucher Defaults',
|
||||||
'settings_tab_cron' => 'Cron Sync',
|
'settings_tab_cron' => 'Cron Sync',
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ class Database {
|
||||||
'trusted_proxy' => '10.0.0.1, 172.18.0.1',
|
'trusted_proxy' => '10.0.0.1, 172.18.0.1',
|
||||||
'cleanup_expired_days' => '90', 'cleanup_audit_days' => '365', 'cleanup_login_days' => '30',
|
'cleanup_expired_days' => '90', 'cleanup_audit_days' => '365', 'cleanup_login_days' => '30',
|
||||||
'last_cleanup' => '2026-09-22 03:00:00',
|
'last_cleanup' => '2026-09-22 03:00:00',
|
||||||
'print_template' => '<div style="padding:20px;border:1px dashed #999;"><h2>{APP_TITLE}</h2><p>{SITE_NAME}</p><h1>{VOUCHER_CODE}</h1></div>',
|
|
||||||
];
|
];
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue