*/ require __DIR__ . '/../app/bootstrap.php'; $lookback = 7; foreach ($argv ?? [] as $arg) { if (preg_match('/^--lookback=(\d+)$/', $arg, $m)) { $lookback = max(1, min(60, (int) $m[1])); } } $push = push_dispatch_due($lookback); $mail = reminder_send_due($lookback); if (!push_is_configured()) { fwrite(STDOUT, "Push: nicht konfiguriert (VAPID-Schlüssel fehlen).\n"); } else { fwrite(STDOUT, sprintf( "Push: %d gesendet, %d fehlgeschlagen, %d abgelaufene Abos entfernt, %d ohne Abo.\n", $push['sent'], $push['failed'], $push['removed'], $push['skipped_no_subscription'] )); } if (!$mail['enabled']) { fwrite(STDOUT, "E-Mail: deaktiviert.\n"); } else { fwrite(STDOUT, sprintf("E-Mail: %d versendet, %d übersprungen.\n", $mail['sent'], $mail['skipped'])); foreach ($mail['details'] as $detail) { fwrite(STDOUT, ' ' . $detail . "\n"); } foreach ($mail['errors'] as $error) { fwrite(STDERR, ' Fehler: ' . $error . "\n"); } } exit(($mail['errors'] || $push['failed'] > 0) ? 1 : 0);