- Mietvertrag als PDF in drei Varianten (Mit Lieferung, Selbstabholer, Truhe), Seite 2+ mit der AGB aus app/agb.php – derselbe Text wie /agb. - Auftragsbestätigung als PDF, ebenfalls in drei Varianten. - PDF-Erzeuger ohne Fremdbibliothek (app/pdf.php, Helvetica + JPEG für die Unterschrift); Layout in app/documents.php. - Unterschrift auf dem Tablet (views/document_sign.php, Canvas -> JPEG) wird ins PDF gesetzt; Unterlagen lassen sich ansehen, drucken und per Mail an den Kunden senden (mail_send_attachment()). - Rechnung aus Lexware als PDF-Upload; Ablage unter storage/documents/<booking_id>/ (per .htaccess gesperrt). - Aufbewahrung: documents_cleanup() im Cron löscht einen Monat nach Mietende (app.document_retention_days), inklusive verwaister Dateien. - Migrationen per HTTP (/migrate?token=…, app/migrate.php), weil das Hosting kein SSH hat; deploy.sh ruft die Route nach dem Sync auf. - Schema: booking_documents (Migration 012, auch in schema.sql), Doku in README/ROADMAP/docs/todo_kundenemail_2026-11-30-unterlagen.md. Enthält außerdem die bislang nicht committeten Anpassungen in bootstrap.php und app.js/pages.php, die im selben Arbeitsstand lagen.
88 lines
3.2 KiB
PHP
88 lines
3.2 KiB
PHP
<?php
|
||
declare(strict_types=1);
|
||
|
||
/**
|
||
* Drink it cold – Bootstrap.
|
||
*
|
||
* Lädt Konfiguration, Datenbank, Session und Helfer. Die Konfiguration mit
|
||
* Zugangsdaten liegt in app/config.local.php und wird beim Deployment erzeugt.
|
||
*/
|
||
|
||
define('DIC_ROOT', dirname(__DIR__));
|
||
define('DIC_APP', __DIR__);
|
||
|
||
$configFile = DIC_APP . '/config.local.php';
|
||
if (!is_file($configFile)) {
|
||
http_response_code(500);
|
||
header('Content-Type: text/plain; charset=utf-8');
|
||
echo "Die Anwendung ist noch nicht konfiguriert (app/config.local.php fehlt).\n";
|
||
exit;
|
||
}
|
||
|
||
$GLOBALS['dic_config'] = require $configFile;
|
||
|
||
date_default_timezone_set('Europe/Berlin');
|
||
ini_set('display_errors', '0');
|
||
ini_set('log_errors', '1');
|
||
|
||
require DIC_APP . '/util.php';
|
||
require DIC_APP . '/legal.php';
|
||
require DIC_APP . '/db.php';
|
||
require DIC_APP . '/webpush.php';
|
||
require DIC_APP . '/auth.php';
|
||
require DIC_APP . '/migrate.php';
|
||
require DIC_APP . '/agb.php';
|
||
require DIC_APP . '/pdf.php';
|
||
require DIC_APP . '/documents.php';
|
||
require DIC_APP . '/data.php';
|
||
require DIC_APP . '/push.php';
|
||
require DIC_APP . '/mail.php';
|
||
require DIC_APP . '/mailing.php';
|
||
require DIC_APP . '/inquiry.php';
|
||
require DIC_APP . '/invite.php';
|
||
require DIC_APP . '/privacy.php';
|
||
require DIC_APP . '/pages.php';
|
||
require DIC_APP . '/admin.php';
|
||
|
||
$storage = (string) config('app.storage_path', DIC_ROOT . '/storage');
|
||
if (is_dir($storage) && is_dir($storage . '/logs') && is_writable($storage . '/logs')) {
|
||
ini_set('error_log', $storage . '/logs/php.log');
|
||
}
|
||
|
||
set_exception_handler(static function (Throwable $error): void {
|
||
error_log('Drink it cold: ' . $error::class . ': ' . $error->getMessage() . ' in ' . $error->getFile() . ':' . $error->getLine());
|
||
if (function_exists('wants_json') && wants_json()) {
|
||
json_response(['error' => ['code' => 'server_error', 'message' => 'Interner Fehler.']], 500);
|
||
return;
|
||
}
|
||
http_response_code(500);
|
||
header('Content-Type: text/html; charset=utf-8');
|
||
echo '<!doctype html><meta charset="utf-8"><title>Fehler 500</title>'
|
||
. '<body style="font-family:system-ui;background:#f4f9fe;color:#0e1b26;padding:2rem">'
|
||
. '<h1>Interner Fehler</h1><p>Bitte später erneut versuchen.</p>'
|
||
. '<p style="font-size:.85rem"><a style="color:#196abc" href="' . e(url('/impressum')) . '">Impressum</a>'
|
||
. ' · <a style="color:#196abc" href="' . e(url('/datenschutz')) . '">Datenschutz</a></p></body>';
|
||
});
|
||
|
||
// Stillgelegtes Deployment: keine Anwendung, keine Anmeldung, nur der Vermerk.
|
||
$retiredUrl = trim((string) config('app.retired_url', ''));
|
||
if ($retiredUrl !== '') {
|
||
if (PHP_SAPI === 'cli') {
|
||
fwrite(STDERR, "Dieses Deployment ist stillgelegt: $retiredUrl\n");
|
||
exit(0);
|
||
}
|
||
retired_notice($retiredUrl);
|
||
exit;
|
||
}
|
||
|
||
if (PHP_SAPI !== 'cli') {
|
||
// Öffentliche Rechtsseiten, Health-Check und Cron brauchen keine Session.
|
||
// So wird auf Impressum/Datenschutz kein unnötiges Sitzungs-Cookie gesetzt.
|
||
$path = current_path();
|
||
$legalPublic = legal_is_public_path($path);
|
||
security_headers($legalPublic);
|
||
$sessionFree = ['/health', '/cron/reminders', '/anfrage', '/abmelden'];
|
||
if (!$legalPublic && !in_array($path, $sessionFree, true)) {
|
||
start_session();
|
||
}
|
||
}
|