This commit is contained in:
torsten 2026-10-29 22:30:01 +01:00
parent 9e6b96fb0d
commit 667ae29560
19 changed files with 1854 additions and 70 deletions

View file

@ -0,0 +1,51 @@
<?php
namespace App\Core;
/**
* Normalisierung und Prüfung von IBANs.
*
* Geprüft wird das Format (Ländercode, Prüfziffer, erlaubte Zeichen, Länge)
* sowie die Mod-97-Prüfziffer nach ISO 13616. Eine länderspezifische
* Längenprüfung ist bewusst nicht enthalten, da die Mod-97-Prüfung
* fehlerhafte Eingaben zuverlässig erkennt.
*/
class Iban {
/**
* Entfernt Leerzeichen/Bindestriche, wandelt in Großbuchstaben und
* entfernt ein eventuell vorangestelltes "IBAN".
*
* @param string $value
* @return string
*/
public static function normalize($value) {
$value = strtoupper(preg_replace('/[\s\-]+/', '', (string)$value));
return preg_replace('/^IBAN/', '', $value);
}
/**
* Prüft eine IBAN auf Format und Mod-97-Prüfziffer.
*
* @param string $value
* @return bool
*/
public static function isValid($value) {
$iban = self::normalize($value);
if (!preg_match('/^[A-Z]{2}[0-9]{2}[A-Z0-9]{10,30}$/', $iban)) {
return false;
}
$rearranged = substr($iban, 4) . substr($iban, 0, 4);
$numeric = '';
foreach (str_split($rearranged) as $char) {
$numeric .= ctype_alpha($char) ? (string)(ord($char) - 55) : $char;
}
$mod = 0;
foreach (str_split($numeric) as $digit) {
$mod = ($mod * 10 + (int)$digit) % 97;
}
return $mod === 1;
}
}

View file

@ -87,25 +87,51 @@ class Mailer {
$this->command('RCPT TO:<' . $to . '>', [250, 251]);
$this->command('DATA', [354]);
$at = strrpos($from, '@');
$domain = $at === false ? 'localhost' : substr($from, $at + 1);
$messageId = '<' . bin2hex(random_bytes(16)) . '@' . $domain . '>';
$boundary = '=_tippspiel_' . bin2hex(random_bytes(12));
$headers = [
'Date: ' . date('r'),
'From: ' . self::encodeHeader($fromName) . ' <' . $from . '>',
'To: <' . $to . '>',
'Subject: ' . self::encodeHeader($subject),
'Message-ID: ' . $messageId,
'X-Mailer: Tippspiel',
'MIME-Version: 1.0',
'Content-Type: text/html; charset=UTF-8',
'Content-Transfer-Encoding: base64',
'Content-Type: multipart/alternative; boundary="' . $boundary . '"',
];
if ($replyTo) {
$headers[] = 'Reply-To: <' . $replyTo . '>';
}
$body = chunk_split(base64_encode($html), 76, "\r\n");
// Text- und HTML-Teil: reine HTML-Mails werden von vielen Filtern
// schlechter bewertet als multipart/alternative.
$body =
'--' . $boundary . "\r\n"
. "Content-Type: text/plain; charset=UTF-8\r\n"
. "Content-Transfer-Encoding: base64\r\n\r\n"
. chunk_split(base64_encode(self::toPlainText($html)), 76, "\r\n")
. '--' . $boundary . "\r\n"
. "Content-Type: text/html; charset=UTF-8\r\n"
. "Content-Transfer-Encoding: base64\r\n\r\n"
. chunk_split(base64_encode($html), 76, "\r\n")
. '--' . $boundary . "--\r\n";
// base64 enthält keine Zeilen, die mit "." beginnen – kein Dot-Stuffing nötig
fwrite($this->socket, implode("\r\n", $headers) . "\r\n\r\n" . $body . ".\r\n");
$this->expect([250]);
}
private static function toPlainText($html) {
$text = preg_replace('/<br\s*\/?>/i', "\n", $html);
$text = preg_replace('/<\/p>/i', "\n\n", $text);
$text = html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8');
$text = preg_replace("/\n{3,}/", "\n\n", $text);
return trim($text);
}
private function command($line, array $expectedCodes) {
fwrite($this->socket, $line . "\r\n");
return $this->expect($expectedCodes);

View file

@ -161,11 +161,7 @@ class Round {
'remaining' => self::formatRemainingTime($secondsLeft),
'missing_tipps' => in_array((int)$userId, $missing['tipps'], true),
'missing_joker' => in_array((int)$userId, $missing['joker'], true),
'missing_payment' => $user
? trim((string)$user['iban']) === '' && trim((string)$user['paypal']) === ''
: false,
'missing_email' => $user ? trim((string)$user['email']) === '' : false,
'missing_mobile' => $user ? trim((string)$user['mobile']) === '' : false,
];
}

View file

@ -57,6 +57,29 @@ class User {
return $stmt->fetch(\PDO::FETCH_ASSOC);
}
/**
* Liefert unabhängig vom Runden-Lock fehlende Profildaten, die für die
* Teilnahme bzw. eine spätere Auszahlung gebraucht werden.
*
* @param int $userId
* @return array z.B. ['missing_payment' => true, 'missing_mobile' => true]
*/
public static function getProfileWarnings($userId) {
$user = self::findById($userId);
if (!$user) {
return [];
}
$warnings = [];
if (trim((string)$user['iban']) === '' && trim((string)$user['paypal']) === '') {
$warnings['missing_payment'] = true;
}
if (trim((string)$user['mobile']) === '') {
$warnings['missing_mobile'] = true;
}
return $warnings;
}
/**
* Prüft, ob der Name "Vorname Nachname" bereits vergeben ist (inkl. gelöschter Benutzer,
* wie im Legacy RegistrationController).

View file

@ -1,13 +1,13 @@
<?php
use App\Models\Round;
$pageTitle = 'Runden-E-Mails versenden';
$pageTitle = 'Rundmails';
require __DIR__ . '/../partials/header.php';
$reminderParam = ($excludeReminders ?? false) ? '&amp;hide_reminders=1' : '';
?>
<h1>Runden-E-Mails</h1>
<h1>Rundmails</h1>
<?php if (!empty($message)): ?>
<p style="color: green;"><?php echo htmlspecialchars($message); ?></p>

View file

@ -6,6 +6,20 @@ $bodyClass = 'home-page';
require __DIR__ . '/partials/header.php';
?>
<?php if (!empty($profileWarnings)): ?>
<div class="lock-warning profile-warning" role="status">
<?php if (!empty($profileWarnings['missing_payment'])): ?>
<p>Fehlende Zahlungsmöglichkeit (IBAN oder PayPal)</p>
<?php endif; ?>
<?php if (!empty($profileWarnings['missing_mobile'])): ?>
<p>Fehlende Handynummer</p>
<?php endif; ?>
<p>
<a class="lock-warning-link" href="/index.php?page=settings">Daten ergänzen</a>
</p>
</div>
<?php endif; ?>
<?php if (!empty($lockWarning)): ?>
<div class="lock-warning" role="status">
<?php if ($lockWarning['missing_tipps']): ?>
@ -14,15 +28,9 @@ require __DIR__ . '/partials/header.php';
<?php if ($lockWarning['missing_joker']): ?>
<p>Fehlender Joker für <?php echo htmlspecialchars($lockWarning['name']); ?></p>
<?php endif; ?>
<?php if ($lockWarning['missing_payment']): ?>
<p>Fehlende Zahlungsmöglichkeit (IBAN oder PayPal)</p>
<?php endif; ?>
<?php if ($lockWarning['missing_email']): ?>
<p>Fehlende E-Mail-Adresse</p>
<?php endif; ?>
<?php if ($lockWarning['missing_mobile']): ?>
<p>Fehlende Handynummer</p>
<?php endif; ?>
<p>
<?php echo htmlspecialchars($lockWarning['name']); ?> sperrt sich:
<?php echo $lockWarning['lock_time']->format('Y-m-d H:i:s'); ?>

View file

@ -55,7 +55,7 @@ ohne alle Spieler umzuschalten:</p>
auf andere Spieler aus.</li>
<li>Die persönliche Ansicht wirkt auf die Verwaltungsseiten
(<em>Spiele &amp; Ergebnisse eintragen</em>, <em>Benutzer verwalten</em>, <em>Kontoliste</em>,
<em>Runden-E-Mails versenden</em>) sowie auf die reinen Ansichtsseiten
<em>Rundmails</em>) sowie auf die reinen Ansichtsseiten
(<em>Startseite</em>, <em>Rangliste</em>, <em>Geldrangliste</em>, <em>Quoten</em>,
<em>Anleitung</em>). Nur die <em>Tippabgabe</em> bleibt immer bei der für alle aktiven
Saison – getippt wird nur in der laufenden Saison.</li>

View file

@ -55,7 +55,7 @@ if (App\Core\Auth::check()) {
<a href="/index.php?page=admin_users">Benutzer verwalten</a>
<a href="/index.php?page=admin_seasons">Saisons verwalten</a>
<a href="/index.php?page=admin_rounds">Spiele &amp; Ergebnisse eintragen</a>
<a href="/index.php?page=admin_roundmails">Runden-E-Mails versenden</a>
<a href="/index.php?page=admin_roundmails">Rundmails</a>
<a href="/index.php?page=admin_accounts">Kontoliste</a>
<a href="/index.php?page=admin_message">Aktuelle Mitteilung</a>
<a href="/index.php?page=admin_fetcher_activity">Robo-Admin Aktivität</a>