From 01dae01c7c813e485ee098f1931be7292278573e Mon Sep 17 00:00:00 2001
From: torsten
Date: Sat, 21 Nov 2026 04:02:29 +0100
Subject: [PATCH] =?UTF-8?q?Charakterverwalter=20(westreiche=5Fwebsite)=20e?=
=?UTF-8?q?rg=C3=A4nzen,=20Website-Nav=20"Charaktere"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 4 +
AGENTS.md | 74 ++
tools/build_site.py | 12 +
tools/build_spell_seed.py | 163 ++++
web/index.php | 10 +-
web/westreiche/index.html | 2 +-
.../protokolle/sitzung-002-geschehnisse.html | 2 +-
.../protokolle/sitzung-003-geschehnisse.html | 2 +-
.../protokolle/sitzung-004-geschehnisse.html | 2 +-
.../protokolle/sitzung-005-geschehnisse.html | 2 +-
.../protokolle/sitzung-006-geschehnisse.html | 2 +-
.../protokolle/sitzung-007-geschehnisse.html | 2 +-
.../protokolle/sitzung-008-geschehnisse.html | 2 +-
.../protokolle/sitzung-009-geschehnisse.html | 2 +-
.../protokolle/sitzung-010-geschehnisse.html | 2 +-
.../protokolle/sitzung-011-geschehnisse.html | 2 +-
.../protokolle/sitzung-012-geschehnisse.html | 2 +-
.../protokolle/sitzung-013-geschehnisse.html | 2 +-
.../protokolle/sitzung-014-geschehnisse.html | 2 +-
web/westreiche/regeln.html | 2 +-
web/westreiche/zauber.html | 2 +-
westreiche_website/.htaccess | 23 +
westreiche_website/README.md | 153 +++
westreiche_website/app/.htaccess | 7 +
westreiche_website/app/auth.php | 337 +++++++
westreiche_website/app/bootstrap.php | 62 ++
westreiche_website/app/character.php | 700 +++++++++++++
westreiche_website/app/config.example.php | 40 +
westreiche_website/app/db.php | 33 +
westreiche_website/app/invite.php | 123 +++
westreiche_website/app/mailer.php | 393 ++++++++
westreiche_website/app/migrations.php | 57 ++
westreiche_website/app/pages.php | 838 ++++++++++++++++
westreiche_website/app/pdf.php | 303 ++++++
westreiche_website/app/portrait.php | 177 ++++
westreiche_website/app/rules.php | 249 +++++
westreiche_website/app/sheet.php | 373 +++++++
westreiche_website/app/util.php | 217 +++++
westreiche_website/assets/app.css | 889 +++++++++++++++++
westreiche_website/assets/app.js | 185 ++++
westreiche_website/assets/crest.svg | 5 +
.../assets/portraits/assassine.webp | Bin 0 -> 37348 bytes
.../assets/portraits/barbar.webp | Bin 0 -> 56060 bytes
.../assets/portraits/barde.webp | Bin 0 -> 52308 bytes
westreiche_website/assets/portraits/dieb.webp | Bin 0 -> 42028 bytes
.../assets/portraits/druide.webp | Bin 0 -> 62862 bytes
.../assets/portraits/illusionist.webp | Bin 0 -> 33992 bytes
.../assets/portraits/kaempfer.webp | Bin 0 -> 67658 bytes
.../assets/portraits/kleriker.webp | Bin 0 -> 50664 bytes
.../assets/portraits/magier.webp | Bin 0 -> 68074 bytes
.../assets/portraits/paladin.webp | Bin 0 -> 83504 bytes
.../assets/portraits/ritter.webp | Bin 0 -> 62224 bytes
.../assets/portraits/waldlaeufer.webp | Bin 0 -> 56740 bytes
westreiche_website/index.php | 32 +
westreiche_website/install.php | 211 ++++
westreiche_website/robots.txt | 2 +
westreiche_website/sql/.htaccess | 7 +
westreiche_website/sql/schema.sql | 261 +++++
westreiche_website/sql/seed_equipment.sql | 36 +
westreiche_website/sql/seed_spells.sql | 921 ++++++++++++++++++
westreiche_website/storage/.gitignore | 3 +
westreiche_website/storage/.htaccess | 7 +
westreiche_website/tools/deploy_app.sh | 108 ++
westreiche_website/tools/router.php | 18 +
westreiche_website/uploads/.gitignore | 4 +
westreiche_website/uploads/.htaccess | 18 +
.../uploads/portraits/.gitignore | 2 +
westreiche_website/views/.htaccess | 7 +
westreiche_website/views/_fields.php | 149 +++
westreiche_website/views/_selector_skills.php | 84 ++
westreiche_website/views/_selector_spells.php | 124 +++
westreiche_website/views/account.php | 66 ++
westreiche_website/views/admin_equipment.php | 48 +
westreiche_website/views/admin_skills.php | 65 ++
westreiche_website/views/admin_spells.php | 57 ++
westreiche_website/views/admin_user_form.php | 104 ++
westreiche_website/views/admin_users.php | 76 ++
westreiche_website/views/character_edit.php | 471 +++++++++
westreiche_website/views/character_form.php | 30 +
westreiche_website/views/character_sheet.php | 295 ++++++
westreiche_website/views/characters.php | 74 ++
westreiche_website/views/invite.php | 48 +
westreiche_website/views/layout.php | 91 ++
westreiche_website/views/login.php | 54 +
84 files changed, 8915 insertions(+), 17 deletions(-)
create mode 100644 tools/build_spell_seed.py
create mode 100644 westreiche_website/.htaccess
create mode 100644 westreiche_website/README.md
create mode 100644 westreiche_website/app/.htaccess
create mode 100644 westreiche_website/app/auth.php
create mode 100644 westreiche_website/app/bootstrap.php
create mode 100644 westreiche_website/app/character.php
create mode 100644 westreiche_website/app/config.example.php
create mode 100644 westreiche_website/app/db.php
create mode 100644 westreiche_website/app/invite.php
create mode 100644 westreiche_website/app/mailer.php
create mode 100644 westreiche_website/app/migrations.php
create mode 100644 westreiche_website/app/pages.php
create mode 100644 westreiche_website/app/pdf.php
create mode 100644 westreiche_website/app/portrait.php
create mode 100644 westreiche_website/app/rules.php
create mode 100644 westreiche_website/app/sheet.php
create mode 100644 westreiche_website/app/util.php
create mode 100644 westreiche_website/assets/app.css
create mode 100644 westreiche_website/assets/app.js
create mode 100644 westreiche_website/assets/crest.svg
create mode 100644 westreiche_website/assets/portraits/assassine.webp
create mode 100644 westreiche_website/assets/portraits/barbar.webp
create mode 100644 westreiche_website/assets/portraits/barde.webp
create mode 100644 westreiche_website/assets/portraits/dieb.webp
create mode 100644 westreiche_website/assets/portraits/druide.webp
create mode 100644 westreiche_website/assets/portraits/illusionist.webp
create mode 100644 westreiche_website/assets/portraits/kaempfer.webp
create mode 100644 westreiche_website/assets/portraits/kleriker.webp
create mode 100644 westreiche_website/assets/portraits/magier.webp
create mode 100644 westreiche_website/assets/portraits/paladin.webp
create mode 100644 westreiche_website/assets/portraits/ritter.webp
create mode 100644 westreiche_website/assets/portraits/waldlaeufer.webp
create mode 100644 westreiche_website/index.php
create mode 100644 westreiche_website/install.php
create mode 100644 westreiche_website/robots.txt
create mode 100644 westreiche_website/sql/.htaccess
create mode 100644 westreiche_website/sql/schema.sql
create mode 100644 westreiche_website/sql/seed_equipment.sql
create mode 100644 westreiche_website/sql/seed_spells.sql
create mode 100644 westreiche_website/storage/.gitignore
create mode 100644 westreiche_website/storage/.htaccess
create mode 100755 westreiche_website/tools/deploy_app.sh
create mode 100644 westreiche_website/tools/router.php
create mode 100644 westreiche_website/uploads/.gitignore
create mode 100644 westreiche_website/uploads/.htaccess
create mode 100644 westreiche_website/uploads/portraits/.gitignore
create mode 100644 westreiche_website/views/.htaccess
create mode 100644 westreiche_website/views/_fields.php
create mode 100644 westreiche_website/views/_selector_skills.php
create mode 100644 westreiche_website/views/_selector_spells.php
create mode 100644 westreiche_website/views/account.php
create mode 100644 westreiche_website/views/admin_equipment.php
create mode 100644 westreiche_website/views/admin_skills.php
create mode 100644 westreiche_website/views/admin_spells.php
create mode 100644 westreiche_website/views/admin_user_form.php
create mode 100644 westreiche_website/views/admin_users.php
create mode 100644 westreiche_website/views/character_edit.php
create mode 100644 westreiche_website/views/character_form.php
create mode 100644 westreiche_website/views/character_sheet.php
create mode 100644 westreiche_website/views/characters.php
create mode 100644 westreiche_website/views/invite.php
create mode 100644 westreiche_website/views/layout.php
create mode 100644 westreiche_website/views/login.php
diff --git a/.gitignore b/.gitignore
index 06aa679..8fa7278 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,3 +78,7 @@ RPG/7-Prep/*/Magazine/*.pdf
RPG/7-Prep/*/MegaDungeons/*.pdf
Druckmaterial/*.pdf
Druckmaterial/**/*.pdf
+
+# Web-App (westreiche_website): lokale Konfiguration und Logs
+westreiche_website/app/config.local.php
+westreiche_website/storage/logs/
diff --git a/AGENTS.md b/AGENTS.md
index 0c942fb..4da72a5 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -13,6 +13,19 @@ Zugangsdaten stehen in `credentials.txt` im Projektwurzelverzeichnis (per
- **Host:** `FTP_URL` aus `credentials.txt` (z. B. `www19.your-server.de`),
Login `FTP_USER`, Passwort `FTP_PASSWORD`.
+### Weitere Schlüssel in `credentials.txt`
+
+- **`APP_DIRECTORY`** (`westreiche_website`) – **ausschließlich** für die
+ geplante Web-App. Alle bestehenden Veröffentlichungen bleiben, wo sie sind:
+ Website/Protokolle/Regel-Changelog weiter nach `public_html/`, PDF-Handouts
+ (Spiel-Zusammenfassungen, Zauber-/Liturgie-Summarien, SL-Material) bleiben
+ lokal in `RPG/7-Prep/…` bzw. am bisherigen Ablageort. Nichts davon in
+ `APP_DIRECTORY` verschieben oder umleiten.
+- **`DB_HOST`** (`mxzh.your-database.de`, Hetzner Managed MariaDB) + `DB_NAME`,
+ `DB_USER`, `DB_PASSWORD` – erreichbar über Port 3306 von außen, DB derzeit
+ ohne Tabellen. **Achtung:** In der Datei steht ein nachgestelltes Leerzeichen,
+ vor Nutzung trimmen (`tr -d '[:space:]'`). Nicht `FTP_URL` als DB-Host nutzen.
+
### Upload-Befehl
```bash
@@ -39,6 +52,67 @@ lädt den Inhalt von `dir/` in das Zielverzeichnis.
`public_html`, `westreiche`, `www_logs`, `tippspiel_backup`, `vmail`,
`.phpversion`, `.tmp`.
+## Web-App: Charakterverwalter (`westreiche_website/`)
+
+Geschlossene PHP/MariaDB-App für Charakterbögen (OSE-alike), technische Basis
+wie `../drink-it-cold` (kein Composer, server-gerendertes HTML). Theme analog
+zauberturm.de: Nachtblau/Schwarz/Gold, Pergament, Animationen.
+
+- **Ort:** `westreiche_website/` im Repo = `public_html/westreiche_website/`
+ auf dem Server (App-Wurzel, `base_path = /westreiche_website`).
+- **Deploy:**
+ ```bash
+ cd westreiche_website && ./tools/deploy_app.sh --dry-run # Vorschau
+ ./tools/deploy_app.sh # hochladen
+ ```
+ Das Skript liest `credentials.txt` und erzeugt `app/config.local.php`
+ (gitignored) mit `DB_HOST/DB_NAME/DB_USER/DB_PASSWORD`, `APP_DIRECTORY`
+ (als `base_path`) und `INSTALL_TOKEN`. `app/`, `views/`, `sql/`, `storage/`
+ sind per `.htaccess` gesperrt.
+- **Installation / erster Admin:** `…/install.php?token=$INSTALL_TOKEN`
+ (legt Tabellen, Kataloge und das erste Admin-Konto an). Eingerichtet:
+ Benutzer `Torsten` mit Rolle `admin`. Danach zeigt `install.php` nur noch
+ einen Hinweis.
+- **Login** mit Benutzername **oder** E-Mail; Konten nur durch den Admin,
+ entweder mit Startpasswort oder per Einladungslink (7 Tage, einmalig).
+- **Datenmodell:** `users`, `user_invites`, `auth_tokens`, `login_attempts`,
+ `characters`, `skills` + `character_skills`, `spells` + `character_spells`,
+ `character_items`, `weapons`/`armors` (Katalog) + `character_weapons`/
+ `character_armors`. Attributsboni nach Hausregel V1.1.
+- **Fertigkeitengruppen:** `WS_SKILL_CATALOG` in `app/rules.php` bildet den
+ Charakterbogen (`RPG/6-Dokumente/Charakterbogen.pdf`) 1:1 ab: 33 Fertigkeiten
+ in den Gruppen **Körper, Wildnis, Sozial, Wissen** (Reihenfolge =
+ `WS_SKILL_GROUPS`). `skills_sync_catalog()` gleicht die DB an diese Liste an –
+ nach Änderungen dort einmal aufrufen (Installer tut es automatisch), alte
+ Einträge landen unter „Sonstiges“.
+- **Startwerte:** neue Bögen bekommen alle Katalogfertigkeiten mit
+ Fertigkeitsstufe = Attributsbonus; Rettungswürfe stammen aus
+ `WS_SAVE_TABLES` (`app/rules.php`, OSE-SRD-Werte, Westreiche-Klassen auf die
+ Grundklassen abgebildet) und werden bei Stufen-/Klassenwechsel neu gesetzt.
+ **Falls der SL eigene RW-Tabellen führt: dort in `app/rules.php` ändern**,
+ nicht in der DB.
+- **Ableitungen im Bogen:** Trefferwurf = Grundangriff + Attributsbonus
+ (Nahkampf STR, Fernkampf DEX) + Waffenbonus; Schaden = Würfel + Bonus;
+ RK = 10 + DEX-Bonus + angelegte Rüstung (Feld `characters.ac` = manueller
+ Override, leer/0 = automatisch). Waffen-/Rüstungskatalog:
+ `sql/seed_equipment.sql`, Admin-Ansicht `/admin/equipment`.
+- **Zauberkatalog** wird aus dem Vault erzeugt:
+ `python3 tools/build_spell_seed.py` → `westreiche_website/sql/seed_spells.sql`
+ (147 arkane Zauber, 74 Liturgien). Nach neuen Zauberdateien erneut bauen,
+ hochladen und in einer frischen Installation einspielen.
+- **PDF-Export:** eigener kleiner PDF-Writer (`app/pdf.php` + `app/sheet.php`),
+ A4-Pergamentbogen mit Goldrahmen – kein Composer, keine externen Dienste.
+ JPEG-Bilder werden als XObject eingebettet.
+- **Porträts:** Upload im Bogen (`POST /characters/{id}/portrait`), serverseitig
+ per GD neu als JPEG kodiert (max. 900 px) nach `uploads/portraits/`
+ (gitignored, PHP-Ausführung dort gesperrt). Ohne Upload greift
+ `assets/portraits/.webp` – 12 gemalte Platzhalter, mit fal.ai
+ (`flux/schnell`) erzeugt; Skript-Idee: Prompts im Chat dokumentiert.
+- **Website-Nav:** `tools/build_site.py` hat `APP_CHARACTERS_URL`
+ (`https://zauberturm.de/westreiche_website/`) – Nav-Punkt „Charaktere“ auf
+ allen Seiten plus Karte auf der Startseite. Nach Änderungen dort
+ `build_site.py` + `deploy_web.sh` laufen lassen.
+
## Website (zauberturm.de)
Statischer Auftritt, aus dem Vault generiert:
diff --git a/tools/build_site.py b/tools/build_site.py
index 837347a..48bd6ee 100644
--- a/tools/build_site.py
+++ b/tools/build_site.py
@@ -36,6 +36,8 @@ YEAR = "2026"
# Galerie-Seite nicht gebaut, der Nav-Punkt und die Startseiten-Karte entfallen.
# Zum Wiederbeleben nur auf True setzen, bauen und deployen.
SHOW_WELTENAUGE = False
+# Charakterverwalter (Web-App, eigene Anwendung unter public_html/westreiche_website)
+APP_CHARACTERS_URL = "https://zauberturm.de/westreiche_website/"
# --------------------------------------------------------------------------- #
@@ -98,6 +100,8 @@ def page(
+ '✦ '
+ nav_item("Regeln", "westreiche/regeln.html", "regeln")
+ '✦ '
+ + f'Charaktere '
+ + '✦ '
+ nav_item("Enshrouded", "enshrouded/enshrouded_stats.html", "enshrouded")
)
footer_projects = "Weltenauge & Westreiche" if SHOW_WELTENAUGE else "Westreiche"
@@ -700,6 +704,14 @@ def build_start(docs: list[Doc], latest: Doc | None) -> None:
datiert, mit Begründung und dem, was am Tisch zu tun ist.
Zum Changelog →
+
+ Werkzeug
+ Charaktere
+ Der Charakterverwalter der Runde: Bögen mit Attributen, Fertigkeiten,
+ Zaubern und Liturgien, Inventar – und als PDF mit an den Spieltisch.
+ Zugang nur per Einladung.
+ Zum Charakterverwalter →
+
Werkzeug
Enshrouded Dashboard
diff --git a/tools/build_spell_seed.py b/tools/build_spell_seed.py
new file mode 100644
index 0000000..86826ae
--- /dev/null
+++ b/tools/build_spell_seed.py
@@ -0,0 +1,163 @@
+#!/usr/bin/env python3
+"""Baut das Zauber-/Liturgie-Seed aus dem Vault.
+
+Liest alle Zauberdateien unter ``RPG/5-Regeln/Zauber/{Arkan,Klerikal}/Grad N``
+und schreibt ``w estreiche_website/sql/seed_spells.sql`` (INSERT IGNORE, damit
+der Installer mehrfach laufen darf).
+
+ python3 tools/build_spell_seed.py
+"""
+
+from __future__ import annotations
+
+import re
+
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[1]
+SPELL_DIR = ROOT / "RPG" / "5-Regeln" / "Zauber"
+OUT = ROOT / "westreiche_website" / "sql" / "seed_spells.sql"
+
+FIELD_RE = re.compile(r"\*\*(?P[^:*]+):\*\*\s*(?P[^·»]+)")
+
+
+def plain(text: str) -> str:
+ """Markdown-Reste entfernen: Wikilinks, Fettungen, Kursiv-Satzzeichen."""
+ text = re.sub(r"\[\[([^|\]]*\|)?([^\]]*)\]\]", r"\2", text)
+ text = text.replace("**", "").replace("''", "")
+ return text.strip()
+
+
+def extract_body(text: str) -> str:
+ """Regeltext für den Detail-Schirm: Abschnitte „Wirkung“ und „Regelhinweise“.
+
+ Stichpunkte werden zu „• “-Zeilen, Absätze bleiben als Leerzeile erhalten.
+ """
+ blocks: list[str] = []
+ for heading in ("Wirkung", "Regelhinweise"):
+ match = re.search(r"^##\s*" + heading + r"\s*$(.*?)(?=^##\s|\Z)", text, re.S | re.M)
+ if not match:
+ continue
+ lines: list[str] = []
+ for raw in match.group(1).splitlines():
+ line = raw.strip()
+ if not line:
+ continue
+ if line.startswith("###"):
+ lines.append(plain(line.lstrip("#").strip()))
+ continue
+ bullet = re.match(r"^([-*])\s+(.*)$", line)
+ line = plain(bullet.group(2) if bullet else line)
+ if line == "":
+ continue
+ lines.append("• " + line if bullet else line)
+ if lines:
+ blocks.append("\n".join(lines))
+ return "\n\n".join(blocks).strip()
+
+
+def parse_file(path: Path, school: str, grade: int) -> dict | None:
+ text = path.read_text(encoding="utf-8", errors="replace")
+ if not text.lstrip().startswith("#"):
+ return None
+ name = path.stem.strip()
+ fields: dict[str, str] = {}
+ for line in text.splitlines()[:12]:
+ if "**Schule:**" in line or "**Dauer:**" in line or "**Klasse:**" in line:
+ for m in FIELD_RE.finditer(line):
+ fields[m.group("key").strip().lower()] = m.group("value").strip()
+ # Kurzfassung: erster Stichpunkt unter "## Wirkung"
+ summary = ""
+ match = re.search(r"##\s*Wirkung\s*(.+?)(?:\n##\s|\Z)", text, re.S)
+ if match:
+ for line in match.group(1).splitlines():
+ line = line.strip()
+ if line.startswith(("-", "*")):
+ summary = re.sub(r"^[-*]\s*", "", line)
+ summary = plain(summary)
+ break
+ return {
+ "name": name,
+ "school": school,
+ "grade": grade,
+ "classes": fields.get("klasse", "")[:120],
+ "tradition": fields.get("schule", "")[:120],
+ "duration": fields.get("dauer", "")[:80],
+ "range_text": fields.get("reichweite", "")[:80],
+ "summary": summary[:400],
+ "body": extract_body(text),
+ }
+
+
+def sql_quote(value: str) -> str:
+ return "'" + value.replace("\\", "\\\\").replace("'", "''") + "'"
+
+
+def main() -> int:
+ if not SPELL_DIR.is_dir():
+ print(f"Zauberordner fehlt: {SPELL_DIR}", file=sys.stderr)
+ return 1
+
+ rows: list[dict] = []
+ for school, folder in (("arkan", "Arkan"), ("klerikal", "Klerikal")):
+ for grade_dir in sorted((SPELL_DIR / folder).glob("Grad *")):
+ match = re.search(r"Grad\s*(\d+)", grade_dir.name)
+ if not match:
+ continue
+ grade = int(match.group(1))
+ for path in sorted(grade_dir.glob("*.md")):
+ row = parse_file(path, school, grade)
+ if row:
+ rows.append(row)
+
+ OUT.parent.mkdir(parents=True, exist_ok=True)
+ lines = [
+ "-- Automatisch erzeugt von tools/build_spell_seed.py – nicht von Hand ändern.",
+ "-- Quelle: RPG/5-Regeln/Zauber/{Arkan,Klerikal}/Grad N/*.md",
+ f"-- {sum(1 for r in rows if r['school'] == 'arkan')} arkane Zauber, "
+ f"{sum(1 for r in rows if r['school'] == 'klerikal')} Liturgien.",
+ "",
+ ]
+ chunk: list[str] = []
+ for row in rows:
+ chunk.append(
+ "({}, {}, {}, {}, {}, {}, {}, {}, {})".format(
+ sql_quote(row["name"]),
+ sql_quote(row["school"]),
+ row["grade"],
+ sql_quote(row["classes"]),
+ sql_quote(row["tradition"]),
+ sql_quote(row["duration"]),
+ sql_quote(row["range_text"]),
+ sql_quote(row["summary"]),
+ sql_quote(row["body"]),
+ )
+ )
+ if len(chunk) == 40:
+ lines.append(
+ "INSERT INTO spells (name, school, grade, classes, tradition, duration, range_text, summary, body) VALUES\n"
+ + ",\n".join(chunk)
+ + "\nON DUPLICATE KEY UPDATE classes = VALUES(classes), tradition = VALUES(tradition),\n"
+ " duration = VALUES(duration), range_text = VALUES(range_text),\n"
+ " summary = VALUES(summary), body = VALUES(body);"
+ )
+ lines.append("")
+ chunk = []
+ if chunk:
+ lines.append(
+ "INSERT INTO spells (name, school, grade, classes, tradition, duration, range_text, summary, body) VALUES\n"
+ + ",\n".join(chunk)
+ + "\nON DUPLICATE KEY UPDATE classes = VALUES(classes), tradition = VALUES(tradition),\n"
+ " duration = VALUES(duration), range_text = VALUES(range_text),\n"
+ " summary = VALUES(summary), body = VALUES(body);"
+ )
+ lines.append("")
+
+ OUT.write_text("\n".join(lines), encoding="utf-8")
+ print(f"{len(rows)} Zauber/Liturgien → {OUT.relative_to(ROOT)}")
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/web/index.php b/web/index.php
index bbfaaaf..4c47e1b 100644
--- a/web/index.php
+++ b/web/index.php
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
@@ -48,6 +48,14 @@
datiert, mit Begründung und dem, was am Tisch zu tun ist.
Zum Changelog →
+
+ Werkzeug
+ Charaktere
+ Der Charakterverwalter der Runde: Bögen mit Attributen, Fertigkeiten,
+ Zaubern und Liturgien, Inventar – und als PDF mit an den Spieltisch.
+ Zugang nur per Einladung.
+ Zum Charakterverwalter →
+
Werkzeug
Enshrouded Dashboard
diff --git a/web/westreiche/index.html b/web/westreiche/index.html
index 65cc74c..32a1711 100644
--- a/web/westreiche/index.html
+++ b/web/westreiche/index.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
diff --git a/web/westreiche/protokolle/sitzung-002-geschehnisse.html b/web/westreiche/protokolle/sitzung-002-geschehnisse.html
index 7f91d98..cd338c3 100644
--- a/web/westreiche/protokolle/sitzung-002-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-002-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 002
diff --git a/web/westreiche/protokolle/sitzung-003-geschehnisse.html b/web/westreiche/protokolle/sitzung-003-geschehnisse.html
index d4e8657..c90ad83 100644
--- a/web/westreiche/protokolle/sitzung-003-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-003-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 003
diff --git a/web/westreiche/protokolle/sitzung-004-geschehnisse.html b/web/westreiche/protokolle/sitzung-004-geschehnisse.html
index 86ccea9..5416e7b 100644
--- a/web/westreiche/protokolle/sitzung-004-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-004-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 004
diff --git a/web/westreiche/protokolle/sitzung-005-geschehnisse.html b/web/westreiche/protokolle/sitzung-005-geschehnisse.html
index 6729ced..e60e90b 100644
--- a/web/westreiche/protokolle/sitzung-005-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-005-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 005
diff --git a/web/westreiche/protokolle/sitzung-006-geschehnisse.html b/web/westreiche/protokolle/sitzung-006-geschehnisse.html
index 357ee95..37e7e29 100644
--- a/web/westreiche/protokolle/sitzung-006-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-006-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 006
diff --git a/web/westreiche/protokolle/sitzung-007-geschehnisse.html b/web/westreiche/protokolle/sitzung-007-geschehnisse.html
index e071b56..d147cb0 100644
--- a/web/westreiche/protokolle/sitzung-007-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-007-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 007
diff --git a/web/westreiche/protokolle/sitzung-008-geschehnisse.html b/web/westreiche/protokolle/sitzung-008-geschehnisse.html
index 441efaa..816d9fe 100644
--- a/web/westreiche/protokolle/sitzung-008-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-008-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 008
diff --git a/web/westreiche/protokolle/sitzung-009-geschehnisse.html b/web/westreiche/protokolle/sitzung-009-geschehnisse.html
index 5cd5645..028e9ec 100644
--- a/web/westreiche/protokolle/sitzung-009-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-009-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 009
diff --git a/web/westreiche/protokolle/sitzung-010-geschehnisse.html b/web/westreiche/protokolle/sitzung-010-geschehnisse.html
index d02e26f..58c8038 100644
--- a/web/westreiche/protokolle/sitzung-010-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-010-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 010
diff --git a/web/westreiche/protokolle/sitzung-011-geschehnisse.html b/web/westreiche/protokolle/sitzung-011-geschehnisse.html
index a24ba6d..0de32df 100644
--- a/web/westreiche/protokolle/sitzung-011-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-011-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 011
diff --git a/web/westreiche/protokolle/sitzung-012-geschehnisse.html b/web/westreiche/protokolle/sitzung-012-geschehnisse.html
index adff485..6550bdc 100644
--- a/web/westreiche/protokolle/sitzung-012-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-012-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 012
diff --git a/web/westreiche/protokolle/sitzung-013-geschehnisse.html b/web/westreiche/protokolle/sitzung-013-geschehnisse.html
index 7b6b091..c059d2a 100644
--- a/web/westreiche/protokolle/sitzung-013-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-013-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 013
diff --git a/web/westreiche/protokolle/sitzung-014-geschehnisse.html b/web/westreiche/protokolle/sitzung-014-geschehnisse.html
index 3d18681..fec58e3 100644
--- a/web/westreiche/protokolle/sitzung-014-geschehnisse.html
+++ b/web/westreiche/protokolle/sitzung-014-geschehnisse.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Sitzung 014
diff --git a/web/westreiche/regeln.html b/web/westreiche/regeln.html
index dde3853..dac0eee 100644
--- a/web/westreiche/regeln.html
+++ b/web/westreiche/regeln.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Regeln
diff --git a/web/westreiche/zauber.html b/web/westreiche/zauber.html
index 737ff13..76ac94c 100644
--- a/web/westreiche/zauber.html
+++ b/web/westreiche/zauber.html
@@ -16,7 +16,7 @@
Zauberturm
Erzählwelten, Karten und Chroniken
-Westreiche ✦ Zauber ✦ Regeln ✦ Enshrouded
+Westreiche ✦ Zauber ✦ Regeln ✦ Charaktere ✦ Enshrouded
Start · Westreiche · Zauber
diff --git a/westreiche_website/.htaccess b/westreiche_website/.htaccess
new file mode 100644
index 0000000..4d5d2af
--- /dev/null
+++ b/westreiche_website/.htaccess
@@ -0,0 +1,23 @@
+# Westreiche – Front Controller
+Options -Indexes
+
+
+ RewriteEngine On
+
+ # Sperrverzeichnisse sind bereits per eigener .htaccess unerreichbar;
+ # alles, was keine echte Datei ist, geht an index.php.
+ RewriteCond %{REQUEST_FILENAME} -f [OR]
+ RewriteCond %{REQUEST_FILENAME} -d
+ RewriteRule ^ - [L]
+
+ RewriteRule ^ index.php [L]
+
+
+
+ Require all denied
+
+
+
+ Header set X-Content-Type-Options "nosniff"
+ Header set X-Robots-Tag "noindex, nofollow, noarchive"
+
diff --git a/westreiche_website/README.md b/westreiche_website/README.md
new file mode 100644
index 0000000..3c94415
--- /dev/null
+++ b/westreiche_website/README.md
@@ -0,0 +1,153 @@
+# Westreiche – Charakterverwalter
+
+Geschlossene Web-App für die Westreiche-Runde: Charakterbögen für OSE-alike
+Charaktere pflegen, Zauber und Liturgien aus dem Vault zuordnen, Inventar
+führen und den Bogen als PDF mitnehmen.
+
+Technische Basis wie beim Schwester-Repo `drink-it-cold`: PHP 8.1+, MariaDB,
+server-gerendertes HTML, kein Composer, keine Build-Tools. Theme analog
+`zauberturm.de` (Nachtblau/Schwarz/Gold, Pergament, Glutfunken, Cinzel/EB
+Garamond) mit Animationen.
+
+## Funktionsumfang
+
+- **Geschlossene Benutzergruppe**: Der Spielleiter legt Konten an oder erzeugt
+ eine **Einladung** (Link, 7 Tage gültig, einmal verwendbar) – der Eingeladene
+ setzt sein Passwort selbst. Anmeldung mit **Benutzername oder E-Mail**.
+- **Rollen**: `admin` (Spielleiter, sieht und bearbeitet alle Bögen, verwaltet
+ Konten und Kataloge) und `user` (eigene Bögen).
+- **Charaktere**: Name, Beiname, Klasse (12 Westreiche-Klassen), Stufe, EP,
+ TP, Rüstungsklasse (aufsteigend), Angriff, Gold, die sechs Attribute mit
+ automatischem Attributsbonus nach Hausregel V1.1, Rettungswürfe, Gottheit,
+ Alter/Größe/Gewicht, Erscheinung, Hintergrund, Notizen, Status
+ (im Spiel / gefallen / Ruhestand).
+- **Rettungswürfe**: kommen aus der Klassentabelle (`WS_SAVE_TABLES` in
+ `app/rules.php`, OSE-SRD-Grundwerte) und werden bei Änderung von Klasse
+ oder Stufe automatisch nachgezogen; einzelne Werte bleiben überschreibbar.
+- **Bewaffnung & Rüstung**: Waffe oder Rüstungsteil zunächst aus dem Katalog
+ wählen (`weapons`/`armors`), danach ist jeder Eintrag frei änderbar
+ (Name, Schadenswürfel, Trefferbonus, RK-Bonus, Notiz, geführt/angelegt).
+ Daraus abgeleitet: **Trefferwurf** = Grundangriff + Attributsbonus
+ (Nahkampf Stärke, Fernkampf Geschick) + Waffenbonus, **Schaden** = Würfel +
+ Attributsbonus, **Rüstungsklasse** = 10 + Geschick + angelegte Rüstung
+ (ein Eintrag im Feld „Rüstungsklasse“ überschreibt die Automatik).
+- **Fertigkeiten**: Katalog (`skills`) genau wie auf dem Charakterbogen
+ (`RPG/6-Dokumente/Charakterbogen.pdf`) in den Gruppen **Körper, Wildnis,
+ Sozial, Wissen** – Quelle ist `WS_SKILL_CATALOG` in `app/rules.php`
+ (33 Fertigkeiten, Attribut + Gruppe). Anzeige und PDF führen je Gruppe eine
+ Tabelle mit Fertigkeit · Attribut · **MOD** (Attributsbonus) · **Stufe**
+ (Bonus) · Notiz. Freie Zusatzfertigkeiten sind weiterhin möglich. Beim Anlegen bekommt **jede** Katalogfertigkeit ihren
+ Startwert (Fertigkeitsstufe = Attributsbonus des zugeordneten Attributs) und
+ erscheint in der Gruppe seines Charakterbogens.
+ Attributsänderungen ziehen diese Startwerte mit, solange sie nicht manuell
+ gesteigert wurden; „Startwerte auffrischen“ erledigt das auf Wunsch auch
+ für alle Werte.
+- **Zauber und Liturgien**: Katalog mit 147 arkanen Zaubern und 74 Liturgien
+ aus `RPG/5-Regeln/Zauber/…` (Schule, Grad, Klasse, Dauer, Reichweite,
+ Kurztext) und Zuordnung pro Charakter (keine Vorbereitungspflicht – die
+ Hausregel kennt kein Vorbereiten von Zaubern).
+- **Inventar**: Gegenstände mit Anzahl, Art, Gewicht, Wert, Notiz und
+ „angelegt“-Status.
+- **Porträt**: Upload per Formular (JPEG/PNG/WebP, max. 5 MB) – serverseitig
+ über GD neu als JPEG kodiert (Metadaten weg, max. 900 px), gespeichert in
+ `uploads/portraits/`. Ohne eigenes Bild greift ein gemaltes
+ **Platzhalterporträt der Klasse** aus `assets/portraits/*.webp`
+ (12 Klassen, per fal.ai erzeugt). Das Porträt steht auch auf dem PDF-Bogen.
+- **PDF-Export**: eigener kleiner PDF-Writer (kein Composer, kein GD) rendert
+ ein A4-Pergamentblatt mit Goldrahmen, Attributkästen, Kampfblock,
+ Rettungswürfen, Fertigkeiten, Zaubern nach Grad, Inventar und Notizen –
+ bei Bedarf über mehrere Seiten.
+
+## Installation
+
+```bash
+# 1. Deployment (erzeugt app/config.local.php aus credentials.txt)
+./tools/deploy_app.sh # oder --dry-run
+# 2. Im Browser öffnen
+https://zauberturm.de/westreiche_website/install.php?token=
+```
+
+Der Installer legt Tabellen, Zauber-/Fertigkeitengrundlage und das erste
+Admin-Konto an. Danach kann `install.php` stehen bleiben – bei vorhandenen
+Konten zeigt es nur noch einen Hinweis.
+
+### Einladungen per E-Mail (SMTP)
+
+`app/mailer.php` ist ein eigener kleiner SMTP-Client (kein Composer): STARTTLS
+auf 587 oder SSL auf 465, AUTH PLAIN/LOGIN, Textmails UTF-8-kodiert. Die Werte
+kommen aus `credentials.txt` (`MAIL_HOST`, `MAIL_PORT`, `MAIL_SECURE`,
+`MAIL_USER`, `MAIL_PASSWORD`, `MAIL_FROM`, `MAIL_FROM_NAME`) und landen beim
+Deployment im Abschnitt `'mail'` von `app/config.local.php`.
+
+- Fehlt `MAIL_*` (oder `MAIL_PASSWORD`), gilt der Versand als nicht
+eingerichtet: Einladungslinks werden wie bisher nur angezeigt.
+- `MAIL_HOST` muss ein Name sein, der im Server-Zertifikat steht – bei Hetzner
+also `www19.your-server.de`; `mail.zauberturm.de` zeigt zwar auf denselben
+Server, passt aber nicht zum Zertifikat (`*.your-server.de`).
+- Fehler landen per `error_log` in `storage/logs/php.log`; die Admin-Maske
+meldet dann „Versand fehlgeschlagen – Link bitte kopieren“.
+
+## Lokal entwickeln
+
+```bash
+cp app/config.example.php app/config.local.php # DB-Zugang eintragen
+php -S 127.0.0.1:8099 -t . tools/router.php
+# http://127.0.0.1:8099/install.php?token=
+```
+
+## Datenmodell
+
+| Tabelle | Zweck |
+|---|---|
+| `users` | Konten (Benutzername/E-Mail, Rolle, Status, `auth_epoch`) |
+| `user_invites` | Einladungstokens (nur SHA-256-Hash) |
+| `auth_tokens` | „Angemeldet bleiben“ (Selector/Validator) |
+| `login_attempts` | Ratenbegrenzung je IP und Konto |
+| `characters` | Charakterbogen-Basisdaten |
+| `skills`, `character_skills` | Fertigkeiten-Katalog und Zuordnung |
+| `spells`, `character_spells` | Zauber/Liturgien-Katalog und Zuordnung |
+| `character_items` | Inventar |
+| `weapons`, `armors` | Waffen- und Rüstungskatalog (Seed: `sql/seed_equipment.sql`) |
+| `character_weapons`, `character_armors` | geführte Waffen und Rüstungsteile |
+
+Porträts liegen als Datei in `uploads/portraits/` (gitignored); die Spalte
+`characters.portrait` hält nur den relativen Pfad.
+
+Sprache und Zeit: Zeitstempel in UTC, Anzeige in Europe/Berlin.
+
+## Kataloge pflegen
+
+Der Zauberkatalog wird aus dem Vault erzeugt:
+
+```bash
+python3 ../tools/build_spell_seed.py # schreibt sql/seed_spells.sql
+```
+
+Nach neuen Zauberdateien im Vault also den Seed neu bauen und die Datei
+hochladen; der Installer führt sie bei einer Neuinstallation aus.
+Der Seed schreibt mit `INSERT … ON DUPLICATE KEY UPDATE`, aktualisiert also
+bestehende Zeilen (Kurztext, Dauer, Reichweite, Klassen und den vollständigen
+Regeltext `body` aus „Wirkung“ + „Regelhinweisen“). Nach einem Vault-Update
+also einfach `seed_spells.sql` hochladen und einmal einspielen – z. B.
+
+```bash
+.venv/bin/python tools/build_spell_seed.py # im Repo-Wurzelverzeichnis
+```
+
+Schema-Erweiterungen für **bestehende** Installationen stehen in
+`app/migrations.php` (`WS_MIGRATIONS`); sie laufen beim ersten `db()`-Aufruf
+automatisch und werden in `schema_migrations` vermerkt. Neue Änderung immer
+hinten mit neuer Versionsnummer anhängen.
+
+Fertigkeiten pflegt der Spielleiter direkt unter *Leitung → Fertigkeiten*.
+
+## Sicherheit
+
+- Passwörter mit Argon2id (Fallback bcrypt), Rehash beim Login.
+- CSRF-Token in jedem Formular, Sessions mit `use_strict_mode` und
+ SameSite=Lax, Session-Epoch-Erhöhung bei Passwortwechsel.
+- `app/`, `views/`, `sql/` und `storage/` per `.htaccess` gesperrt; in
+ `uploads/` ist die PHP-Ausführung abgeschaltet (nur Bilder werden
+ ausgeliefert);
+ `config.local.php` liegt nur auf dem Server (in `.gitignore`).
+- CSP ohne externe Quellen, `X-Robots-Tag: noindex` (geschlossene Runde).
diff --git a/westreiche_website/app/.htaccess b/westreiche_website/app/.htaccess
new file mode 100644
index 0000000..7625314
--- /dev/null
+++ b/westreiche_website/app/.htaccess
@@ -0,0 +1,7 @@
+
+ Require all denied
+
+
+ Order allow,deny
+ Deny from all
+
diff --git a/westreiche_website/app/auth.php b/westreiche_website/app/auth.php
new file mode 100644
index 0000000..0ce4268
--- /dev/null
+++ b/westreiche_website/app/auth.php
@@ -0,0 +1,337 @@
+ 32768,
+ 'time_cost' => 3,
+ 'threads' => 1,
+ ]);
+ }
+ return password_hash($password, PASSWORD_DEFAULT);
+}
+
+function password_needs_upgrade(string $hash): bool
+{
+ if (defined('PASSWORD_ARGON2ID')) {
+ return password_needs_rehash($hash, PASSWORD_ARGON2ID, [
+ 'memory_cost' => 32768,
+ 'time_cost' => 3,
+ 'threads' => 1,
+ ]);
+ }
+ return password_needs_rehash($hash, PASSWORD_DEFAULT);
+}
+
+function auth_user(): ?array
+{
+ static $loaded = false;
+ static $user = null;
+ if ($loaded) {
+ return $user;
+ }
+ $loaded = true;
+
+ $uid = $_SESSION['uid'] ?? null;
+ if (!is_int($uid) && !ctype_digit((string) $uid)) {
+ auth_restore_from_remember();
+ $uid = $_SESSION['uid'] ?? null;
+ if (!is_int($uid) && !ctype_digit((string) $uid)) {
+ return null;
+ }
+ }
+
+ $stmt = db()->prepare('SELECT * FROM users WHERE id = ? LIMIT 1');
+ $stmt->execute([(int) $uid]);
+ $row = $stmt->fetch();
+ if (!$row || $row['status'] !== 'active') {
+ auth_clear_session();
+ return null;
+ }
+ if ((int) ($_SESSION['epoch'] ?? 0) !== (int) $row['auth_epoch']) {
+ auth_clear_session();
+ return null;
+ }
+
+ $now = time();
+ $idleLimit = (int) config('app.session_idle_seconds', 2592000);
+ $absoluteLimit = (int) config('app.session_absolute_seconds', 7776000);
+ $created = (int) ($_SESSION['created'] ?? 0);
+ $lastSeen = (int) ($_SESSION['last_seen'] ?? 0);
+ if ($created === 0 || $lastSeen === 0
+ || $now - $lastSeen > $idleLimit
+ || $now - $created > $absoluteLimit
+ ) {
+ auth_clear_session();
+ return null;
+ }
+ if ($now - $lastSeen > 300) {
+ $_SESSION['last_seen'] = $now;
+ }
+
+ $row['id'] = (int) $row['id'];
+ $row['auth_epoch'] = (int) $row['auth_epoch'];
+ $row['must_change_password'] = (int) $row['must_change_password'];
+ $user = $row;
+ return $user;
+}
+
+function auth_user_by_id(int $id): ?array
+{
+ $stmt = db()->prepare('SELECT * FROM users WHERE id = ? LIMIT 1');
+ $stmt->execute([$id]);
+ $row = $stmt->fetch();
+ if (!$row) {
+ return null;
+ }
+ $row['id'] = (int) $row['id'];
+ $row['auth_epoch'] = (int) $row['auth_epoch'];
+ $row['must_change_password'] = (int) $row['must_change_password'];
+ return $row;
+}
+
+function auth_login(array $user, bool $remember = false): void
+{
+ session_regenerate_id(true);
+ $_SESSION['uid'] = (int) $user['id'];
+ $_SESSION['epoch'] = (int) $user['auth_epoch'];
+ $_SESSION['created'] = time();
+ $_SESSION['last_seen'] = time();
+ $_SESSION['csrf'] = bin2hex(random_bytes(32));
+
+ db()->prepare('UPDATE users SET last_login_at = ? WHERE id = ?')
+ ->execute([utc_now(), (int) $user['id']]);
+ db()->prepare('DELETE FROM login_attempts WHERE login_key = ?')
+ ->execute([auth_login_key((string) $user['username'])]);
+
+ if ($remember) {
+ auth_issue_remember((int) $user['id']);
+ }
+}
+
+function auth_clear_session(): void
+{
+ $_SESSION = [];
+ if (session_status() === PHP_SESSION_ACTIVE) {
+ session_regenerate_id(true);
+ }
+}
+
+function auth_logout(): void
+{
+ auth_forget_remember();
+ auth_clear_session();
+ if (session_status() === PHP_SESSION_ACTIVE) {
+ session_destroy();
+ }
+}
+
+function auth_require_login(): array
+{
+ $user = auth_user();
+ if ($user === null) {
+ $target = current_path();
+ $query = (string) ($_SERVER['QUERY_STRING'] ?? '');
+ if ($query !== '') {
+ $target .= '?' . $query;
+ }
+ redirect('/login?next=' . rawurlencode($target));
+ }
+ return $user;
+}
+
+function auth_require_admin(): array
+{
+ $user = auth_require_login();
+ if (($user['role'] ?? '') !== 'admin') {
+ abort_page(403, 'Diese Seite ist nur für den Spielleiter bestimmt.');
+ }
+ return $user;
+}
+
+function auth_login_key(string $identifier): string
+{
+ return mb_strtolower(trim($identifier), 'UTF-8');
+}
+
+function auth_find_by_login(string $identifier): ?array
+{
+ $needle = trim($identifier);
+ if ($needle === '') {
+ return null;
+ }
+ $stmt = db()->prepare(
+ 'SELECT * FROM users WHERE username = ? OR (email IS NOT NULL AND email <> \'\' AND email = ?) LIMIT 1'
+ );
+ $stmt->execute([$needle, $needle]);
+ $row = $stmt->fetch();
+ return $row ?: null;
+}
+
+function auth_username_taken(string $username, int $ignoreId = 0): bool
+{
+ $stmt = db()->prepare('SELECT id FROM users WHERE username = ? AND id <> ? LIMIT 1');
+ $stmt->execute([$username, $ignoreId]);
+ return (bool) $stmt->fetchColumn();
+}
+
+function auth_email_taken(string $email, int $ignoreId = 0): bool
+{
+ if ($email === '') {
+ return false;
+ }
+ $stmt = db()->prepare('SELECT id FROM users WHERE email = ? AND id <> ? LIMIT 1');
+ $stmt->execute([$email, $ignoreId]);
+ return (bool) $stmt->fetchColumn();
+}
+
+function auth_is_locked_out(string $identifier): bool
+{
+ $window = (int) config('app.login_window_seconds', 900);
+ $maxIp = (int) config('app.login_max_per_ip', 15);
+ $maxUser = (int) config('app.login_max_per_user', 5);
+
+ $stmt = db()->prepare('SELECT COUNT(*) FROM login_attempts WHERE ip = ? AND attempted_at >= ?');
+ $stmt->execute([client_ip(), utc_after(-$window)]);
+ if ((int) $stmt->fetchColumn() >= $maxIp) {
+ return true;
+ }
+
+ $stmt = db()->prepare('SELECT COUNT(*) FROM login_attempts WHERE login_key = ? AND attempted_at >= ?');
+ $stmt->execute([auth_login_key($identifier), utc_after(-$window)]);
+ return (int) $stmt->fetchColumn() >= $maxUser;
+}
+
+function auth_record_failure(string $identifier): void
+{
+ db()->prepare('INSERT INTO login_attempts (ip, login_key, attempted_at) VALUES (?, ?, ?)')
+ ->execute([client_ip(), auth_login_key($identifier), utc_now()]);
+
+ $window = (int) config('app.login_window_seconds', 900);
+ db()->prepare('DELETE FROM login_attempts WHERE attempted_at < ?')
+ ->execute([utc_after(-max($window * 8, 86400))]);
+}
+
+function auth_verify_login(string $identifier, string $password): array
+{
+ if (auth_is_locked_out($identifier)) {
+ throw new RuntimeException('locked');
+ }
+
+ $user = auth_find_by_login($identifier);
+ $hash = $user['password_hash'] ?? WS_DUMMY_HASH;
+ $ok = password_verify($password, $hash);
+ if (!$user || !$ok) {
+ auth_record_failure($identifier);
+ throw new RuntimeException('invalid');
+ }
+ if ($user['status'] !== 'active') {
+ auth_record_failure($identifier);
+ throw new RuntimeException('disabled');
+ }
+ if (password_needs_upgrade($hash)) {
+ db()->prepare('UPDATE users SET password_hash = ?, updated_at = ? WHERE id = ?')
+ ->execute([hash_password($password), utc_now(), (int) $user['id']]);
+ }
+ return $user;
+}
+
+function auth_invalidate_sessions(int $userId): void
+{
+ db()->prepare('UPDATE users SET auth_epoch = auth_epoch + 1, updated_at = ? WHERE id = ?')
+ ->execute([utc_now(), $userId]);
+ db()->prepare('DELETE FROM auth_tokens WHERE user_id = ?')->execute([$userId]);
+}
+
+function auth_can_manage(?array $user): bool
+{
+ return is_array($user) && ($user['role'] ?? '') === 'admin';
+}
+
+/* ------------------------------------------------------ Angemeldet bleiben */
+
+function auth_issue_remember(int $userId): void
+{
+ $selector = bin2hex(random_bytes(12));
+ $validator = bin2hex(random_bytes(32));
+ $lifetime = (int) config('app.remember_seconds', 7776000);
+
+ db()->prepare('DELETE FROM auth_tokens WHERE expires_at < ?')->execute([utc_now()]);
+ db()->prepare('INSERT INTO auth_tokens (user_id, selector, validator_hash, created_at, expires_at) VALUES (?, ?, ?, ?, ?)')
+ ->execute([$userId, $selector, hash('sha256', $validator), utc_now(), utc_after($lifetime)]);
+
+ setcookie(WS_REMEMBER_COOKIE, $selector . '.' . $validator, [
+ 'expires' => time() + $lifetime,
+ 'path' => '/',
+ 'secure' => is_https(),
+ 'httponly' => true,
+ 'samesite' => 'Lax',
+ ]);
+}
+
+function auth_forget_remember(): void
+{
+ $raw = $_COOKIE[WS_REMEMBER_COOKIE] ?? '';
+ if (is_string($raw) && str_contains($raw, '.')) {
+ [$selector] = explode('.', $raw, 2);
+ if ($selector !== '') {
+ db()->prepare('DELETE FROM auth_tokens WHERE selector = ?')->execute([$selector]);
+ }
+ }
+ if (isset($_COOKIE[WS_REMEMBER_COOKIE])) {
+ setcookie(WS_REMEMBER_COOKIE, '', [
+ 'expires' => time() - 3600,
+ 'path' => '/',
+ 'secure' => is_https(),
+ 'httponly' => true,
+ 'samesite' => 'Lax',
+ ]);
+ unset($_COOKIE[WS_REMEMBER_COOKIE]);
+ }
+}
+
+function auth_restore_from_remember(): void
+{
+ $raw = $_COOKIE[WS_REMEMBER_COOKIE] ?? '';
+ if (!is_string($raw) || preg_match('/^([a-f0-9]{24})\.([a-f0-9]{64})$/', $raw, $m) !== 1) {
+ return;
+ }
+ $stmt = db()->prepare(
+ 'SELECT t.*, u.auth_epoch, u.status
+ FROM auth_tokens t JOIN users u ON u.id = t.user_id
+ WHERE t.selector = ? AND t.expires_at >= ? LIMIT 1'
+ );
+ $stmt->execute([$m[1], utc_now()]);
+ $token = $stmt->fetch();
+ if (!$token || !hash_equals((string) $token['validator_hash'], hash('sha256', $m[2]))) {
+ auth_forget_remember();
+ return;
+ }
+ if ($token['status'] !== 'active') {
+ auth_forget_remember();
+ return;
+ }
+
+ // Token rotieren, damit ein gestohlenes Cookie nur einmal nutzbar ist.
+ db()->prepare('DELETE FROM auth_tokens WHERE id = ?')->execute([(int) $token['id']]);
+ session_regenerate_id(true);
+ $_SESSION['uid'] = (int) $token['user_id'];
+ $_SESSION['epoch'] = (int) $token['auth_epoch'];
+ $_SESSION['created'] = time();
+ $_SESSION['last_seen'] = time();
+ $_SESSION['csrf'] = bin2hex(random_bytes(32));
+ auth_issue_remember((int) $token['user_id']);
+}
diff --git a/westreiche_website/app/bootstrap.php b/westreiche_website/app/bootstrap.php
new file mode 100644
index 0000000..ed4d8f5
--- /dev/null
+++ b/westreiche_website/app/bootstrap.php
@@ -0,0 +1,62 @@
+getMessage() . ' in ' . $error->getFile() . ':' . $error->getLine());
+ http_response_code(500);
+ header('Content-Type: text/html; charset=utf-8');
+ echo 'Fehler 500 '
+ . ''
+ . 'Die Sterne stehen ungünstig '
+ . 'Es ist ein interner Fehler aufgetreten. Bitte später erneut versuchen.
'
+ . 'Zurück
';
+});
+
+if (PHP_SAPI !== 'cli') {
+ security_headers();
+ if (current_path() !== '/health') {
+ start_session();
+ }
+}
diff --git a/westreiche_website/app/character.php b/westreiche_website/app/character.php
new file mode 100644
index 0000000..99aecb1
--- /dev/null
+++ b/westreiche_website/app/character.php
@@ -0,0 +1,700 @@
+query(
+ 'SELECT c.*, u.username AS owner_name
+ FROM characters c JOIN users u ON u.id = c.user_id
+ ORDER BY u.username, c.sort_order, c.name'
+ )->fetchAll();
+ }
+ $stmt = db()->prepare(
+ 'SELECT c.*, u.username AS owner_name
+ FROM characters c JOIN users u ON u.id = c.user_id
+ WHERE c.user_id = ?
+ ORDER BY c.sort_order, c.name'
+ );
+ $stmt->execute([(int) $user['id']]);
+ return $stmt->fetchAll();
+}
+
+function character_find(int $id): ?array
+{
+ $stmt = db()->prepare(
+ 'SELECT c.*, u.username AS owner_name FROM characters c JOIN users u ON u.id = c.user_id WHERE c.id = ? LIMIT 1'
+ );
+ $stmt->execute([$id]);
+ $row = $stmt->fetch();
+ return $row ?: null;
+}
+
+/** Charakter laden und Zugriff prüfen: eigener Charakter oder Admin. */
+function character_require(int $id, array $user): array
+{
+ $character = character_find($id);
+ if ($character === null) {
+ abort_page(404, 'Diesen Charakter gibt es nicht (mehr).');
+ }
+ if (!auth_can_manage($user) && (int) $character['user_id'] !== (int) $user['id']) {
+ abort_page(403, 'Dieser Charakter gehört zu einem anderen Konto.');
+ }
+ return $character;
+}
+
+function character_status_label(string $status): string
+{
+ return WS_CHARACTER_STATUS[$status] ?? $status;
+}
+
+function character_create(int $userId, array $data): int
+{
+ // Rettungswürfe starten auf dem Klassenwert der Stufe 1
+ // (Hausregel: Klasse + Stufe bestimmen den Grundwert).
+ $data = array_merge($data, saving_throws_for((string) ($data['class_name'] ?? 'Kämpfer'), (int) ($data['level'] ?? 1)));
+
+ $stmt = db()->prepare(
+ 'INSERT INTO characters (user_id, name, title, class_name, level, xp, hp_max, hp_current, ac, attack_bonus,
+ attr_str, attr_dex, attr_con, attr_int, attr_wis, attr_cha,
+ save_death, save_wand, save_paralysis, save_breath, save_spell,
+ alignment, created_at, updated_at)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
+ );
+ $stmt->execute([
+ $userId,
+ $data['name'],
+ $data['title'] ?? '',
+ $data['class_name'] ?? 'Kämpfer',
+ $data['level'] ?? 1,
+ $data['xp'] ?? 0,
+ $data['hp_max'] ?? 1,
+ $data['hp_current'] ?? $data['hp_max'] ?? 1,
+ character_ac_value($data['ac'] ?? null),
+ $data['attack_bonus'] ?? 0,
+ $data['attr_str'] ?? 10,
+ $data['attr_dex'] ?? 10,
+ $data['attr_con'] ?? 10,
+ $data['attr_int'] ?? 10,
+ $data['attr_wis'] ?? 10,
+ $data['attr_cha'] ?? 10,
+ $data['save_death'] ?? null,
+ $data['save_wand'] ?? null,
+ $data['save_paralysis'] ?? null,
+ $data['save_breath'] ?? null,
+ $data['save_spell'] ?? null,
+ $data['alignment'] ?? '',
+ utc_now(),
+ utc_now(),
+ ]);
+ $id = (int) db()->lastInsertId();
+ character_seed_skills($id);
+ return $id;
+}
+
+/**
+ * Trägt alle Katalog-Fertigkeiten mit ihrem Startwert ein
+ * (Fertigkeitsstufe = Attributsbonus des zugeordneten Attributs).
+ */
+/**
+ * Gleicht den Fertigkeitenkatalog mit WS_SKILL_CATALOG ab: fehlende Einträge
+ * anlegen, Attribut/Gruppe nachziehen, alte Einträge in „Sonstiges“ parken.
+ */
+function skills_sync_catalog(): array
+{
+ $existing = [];
+ foreach (skills_catalog() as $skill) {
+ $existing[(string) $skill['name']] = $skill;
+ }
+ $insert = db()->prepare('INSERT INTO skills (name, attribute, category, sort_order) VALUES (?, ?, ?, ?)');
+ $update = db()->prepare('UPDATE skills SET attribute = ?, category = ?, sort_order = ? WHERE id = ?');
+ $order = 0;
+ $created = 0;
+ $updated = 0;
+ foreach (WS_SKILL_CATALOG as $name => [$attribute, $group]) {
+ $order += 10;
+ if (!isset($existing[$name])) {
+ $insert->execute([$name, $attribute, $group, $order]);
+ $created++;
+ continue;
+ }
+ $skill = $existing[$name];
+ if ((string) $skill['attribute'] !== $attribute || (string) $skill['category'] !== $group) {
+ $update->execute([$attribute, $group, $order, (int) $skill['id']]);
+ $updated++;
+ }
+ unset($existing[$name]);
+ }
+ // Nicht mehr im Bogen geführte Fertigkeiten bleiben erhalten, aber gruppiert.
+ $park = db()->prepare("UPDATE skills SET category = 'Sonstiges' WHERE id = ? AND category <> 'Sonstiges'");
+ foreach ($existing as $skill) {
+ $park->execute([(int) $skill['id']]);
+ }
+ return ['created' => $created, 'updated' => $updated];
+}
+
+function character_seed_skills(int $characterId): int
+{
+ $character = character_find($characterId);
+ if ($character === null) {
+ return 0;
+ }
+ $insert = db()->prepare(
+ 'INSERT INTO character_skills (character_id, skill_id, name, bonus, note) VALUES (?, ?, ?, ?, \'\')
+ ON DUPLICATE KEY UPDATE skill_id = VALUES(skill_id)'
+ );
+ $count = 0;
+ foreach (skills_catalog() as $skill) {
+ $attribute = trim((string) ($skill['attribute'] ?? ''));
+ $bonus = $attribute === '' ? 0 : attribute_bonus((int) ($character['attr_' . strtolower($attribute)] ?? 10));
+ $insert->execute([$characterId, (int) $skill['id'], (string) $skill['name'], $bonus]);
+ $count++;
+ }
+ return $count;
+}
+
+/**
+ * Startwerte der Fertigkeiten auf die aktuellen Attributsboni zurücksetzen.
+ * Manuell erhöhte Werte (Bonus weicht vom Startwert ab) bleiben unberührt,
+ * außer bei $force = true.
+ */
+function character_reset_skills(int $characterId, bool $force = false): int
+{
+ $character = character_find($characterId);
+ if ($character === null) {
+ return 0;
+ }
+ $catalog = [];
+ foreach (skills_catalog() as $skill) {
+ $catalog[(int) $skill['id']] = $skill;
+ }
+ $changed = 0;
+ $update = db()->prepare('UPDATE character_skills SET bonus = ? WHERE id = ?');
+ foreach (character_skills($characterId) as $row) {
+ $skill = $catalog[(int) ($row['skill_id'] ?? 0)] ?? null;
+ if ($skill === null) {
+ continue;
+ }
+ $attribute = trim((string) ($skill['attribute'] ?? ''));
+ if ($attribute === '') {
+ continue;
+ }
+ $target = attribute_bonus((int) ($character['attr_' . strtolower($attribute)] ?? 10));
+ if ($force || (int) $row['bonus'] === $target) {
+ $update->execute([$target, (int) $row['id']]);
+ $changed++;
+ }
+ }
+ return $changed;
+}
+
+/** Basisdaten aktualisieren (Name, Klasse, Werte, Rettungswürfe, Notizen). */
+function character_update(int $id, array $d): void
+{
+ $before = character_find($id);
+
+ // Stufe oder Klasse geändert? Dann kommen die Rettungswürfe aus der Tabelle.
+ if ($before !== null) {
+ $levelChanged = (int) $before['level'] !== (int) ($d['level'] ?? 1);
+ $classChanged = (string) $before['class_name'] !== (string) ($d['class_name'] ?? '');
+ if ($levelChanged || $classChanged) {
+ $d = array_merge($d, saving_throws_for((string) ($d['class_name'] ?? 'Kämpfer'), (int) ($d['level'] ?? 1)));
+ }
+ }
+
+ $stmt = db()->prepare(
+ 'UPDATE characters SET name = ?, title = ?, class_name = ?, level = ?, xp = ?, hp_max = ?, hp_current = ?,
+ ac = ?, attack_bonus = ?, attr_str = ?, attr_dex = ?, attr_con = ?, attr_int = ?, attr_wis = ?, attr_cha = ?,
+ save_death = ?, save_wand = ?, save_paralysis = ?, save_breath = ?, save_spell = ?,
+ alignment = ?, deity = ?, age = ?, height = ?, weight = ?, gold_coins = ?,
+ appearance = ?, background = ?, notes = ?, status = ?, updated_at = ?
+ WHERE id = ?'
+ );
+ $stmt->execute([
+ $d['name'],
+ $d['title'] ?? '',
+ $d['class_name'] ?? 'Kämpfer',
+ $d['level'] ?? 1,
+ $d['xp'] ?? 0,
+ $d['hp_max'] ?? 1,
+ $d['hp_current'] ?? 1,
+ character_ac_value($d['ac'] ?? null),
+ $d['attack_bonus'] ?? 0,
+ $d['attr_str'] ?? 10,
+ $d['attr_dex'] ?? 10,
+ $d['attr_con'] ?? 10,
+ $d['attr_int'] ?? 10,
+ $d['attr_wis'] ?? 10,
+ $d['attr_cha'] ?? 10,
+ $d['save_death'] ?? null,
+ $d['save_wand'] ?? null,
+ $d['save_paralysis'] ?? null,
+ $d['save_breath'] ?? null,
+ $d['save_spell'] ?? null,
+ $d['alignment'] ?? '',
+ $d['deity'] ?? '',
+ $d['age'] ?? '',
+ $d['height'] ?? '',
+ $d['weight'] ?? '',
+ $d['gold_coins'] ?? 0,
+ $d['appearance'] ?? '',
+ $d['background'] ?? '',
+ $d['notes'] ?? '',
+ $d['status'] ?? 'active',
+ utc_now(),
+ $id,
+ ]);
+
+ // Attributsänderungen ziehen die Startwerte der Fertigkeiten mit,
+ // solange sie nicht manuell verändert wurden.
+ if ($before !== null) {
+ $attributes = ['str', 'dex', 'con', 'int', 'wis', 'cha'];
+ $shifted = false;
+ foreach ($attributes as $attribute) {
+ if ((int) ($before['attr_' . $attribute] ?? 10) !== (int) ($d['attr_' . $attribute] ?? 10)) {
+ $shifted = true;
+ break;
+ }
+ }
+ if ($shifted) {
+ character_reset_skills($id);
+ }
+ }
+}
+
+/** Rüstungsklasse: leer/0 bedeutet „automatisch aus der Rüstung“. */
+function character_ac_value(mixed $value): ?int
+{
+ if ($value === null || $value === '') {
+ return null;
+ }
+ $int = (int) $value;
+ return $int > 0 ? $int : null;
+}
+
+function character_delete(int $id): void
+{
+ db()->prepare('DELETE FROM characters WHERE id = ?')->execute([$id]);
+}
+
+/** Abgeleitete Anzeigewerte (Boni, Trefferpunkte-Status, Zauberplätze-Gruppe). */
+function character_derived(array $c): array
+{
+ $bonuses = [];
+ foreach (WS_ATTRIBUTES as $field => [, $label]) {
+ $bonuses[$field] = attribute_bonus((int) ($c[$field] ?? 10));
+ }
+ $hp = max(0, (int) $c['hp_current']);
+ $hpMax = max(1, (int) $c['hp_max']);
+ return [
+ 'bonuses' => $bonuses,
+ 'hp_ratio' => min(1.0, $hp / $hpMax),
+ 'hp_state' => $hp <= 0 ? 'unconscious' : ($hp <= $hpMax / 4 ? 'critical' : ($hp < $hpMax / 2 ? 'wounded' : 'healthy')),
+ 'str_damage' => $bonuses['attr_str'],
+ ];
+}
+
+/* ---------------------------------------------------------- Fertigkeiten */
+
+function skills_catalog(): array
+{
+ return db()->query('SELECT * FROM skills ORDER BY sort_order, name')->fetchAll();
+}
+
+function skills_catalog_add(string $name, string $attribute, string $category): void
+{
+ $max = (int) db()->query('SELECT COALESCE(MAX(sort_order), 0) FROM skills')->fetchColumn();
+ db()->prepare('INSERT INTO skills (name, attribute, category, sort_order) VALUES (?, ?, ?, ?)')
+ ->execute([$name, $attribute, $category, $max + 10]);
+}
+
+function skills_catalog_delete(int $id): void
+{
+ db()->prepare('DELETE FROM skills WHERE id = ?')->execute([$id]);
+}
+
+function character_skills(int $characterId): array
+{
+ $stmt = db()->prepare(
+ 'SELECT cs.*, s.attribute, s.category FROM character_skills cs
+ LEFT JOIN skills s ON s.id = cs.skill_id
+ WHERE cs.character_id = ? ORDER BY cs.name'
+ );
+ $stmt->execute([$characterId]);
+ return $stmt->fetchAll();
+}
+
+function character_skill_add(int $characterId, ?int $skillId, string $name, int $bonus, string $note): void
+{
+ if ($skillId !== null && $name === '') {
+ $stmt = db()->prepare('SELECT name FROM skills WHERE id = ?');
+ $stmt->execute([$skillId]);
+ $name = (string) ($stmt->fetchColumn() ?: '');
+ }
+ if ($name === '') {
+ return;
+ }
+ db()->prepare(
+ 'INSERT INTO character_skills (character_id, skill_id, name, bonus, note) VALUES (?, ?, ?, ?, ?)
+ ON DUPLICATE KEY UPDATE bonus = VALUES(bonus), note = VALUES(note), skill_id = VALUES(skill_id)'
+ )->execute([$characterId, $skillId, shorten($name, 80), $bonus, shorten($note, 255)]);
+}
+
+function character_skill_delete(int $characterId, int $id): void
+{
+ db()->prepare('DELETE FROM character_skills WHERE id = ? AND character_id = ?')->execute([$id, $characterId]);
+}
+
+/* ------------------------------------------------------- Zauber/Liturgien */
+
+function spells_search(string $school, int $grade, string $needle = '', int $limit = 60): array
+{
+ $sql = 'SELECT * FROM spells WHERE school = ?';
+ $args = [$school];
+ if ($grade > 0) {
+ $sql .= ' AND grade = ?';
+ $args[] = $grade;
+ }
+ if ($needle !== '') {
+ $sql .= ' AND name LIKE ?';
+ $args[] = '%' . $needle . '%';
+ }
+ $sql .= ' ORDER BY grade, name LIMIT ' . max(1, $limit);
+ $stmt = db()->prepare($sql);
+ $stmt->execute($args);
+ return $stmt->fetchAll();
+}
+
+function spell_find(int $id): ?array
+{
+ $stmt = db()->prepare('SELECT * FROM spells WHERE id = ? LIMIT 1');
+ $stmt->execute([$id]);
+ return $stmt->fetch() ?: null;
+}
+
+function character_spells(int $characterId): array
+{
+ $stmt = db()->prepare(
+ 'SELECT cs.*, s.classes, s.duration, s.range_text, s.summary, s.body
+ FROM character_spells cs LEFT JOIN spells s ON s.id = cs.spell_id
+ WHERE cs.character_id = ? ORDER BY cs.school, cs.grade, cs.name'
+ );
+ $stmt->execute([$characterId]);
+ $rows = $stmt->fetchAll();
+ return ['arkan' => array_values(array_filter($rows, static fn ($r) => $r['school'] === 'arkan')),
+ 'klerikal' => array_values(array_filter($rows, static fn ($r) => $r['school'] === 'klerikal'))];
+}
+
+/** Zauber sind in Westreiche nicht vorbereitungspflichtig – prepared wird nicht mehr geführt. */
+function character_spell_add(int $characterId, ?int $spellId, string $name, string $school, int $grade, string $note): void
+{
+ if ($spellId !== null) {
+ $spell = spell_find($spellId);
+ if ($spell !== null) {
+ $name = $name !== '' ? $name : (string) $spell['name'];
+ $school = (string) $spell['school'];
+ $grade = (int) $spell['grade'];
+ }
+ }
+ if ($name === '') {
+ return;
+ }
+ if (!in_array($school, ['arkan', 'klerikal'], true)) {
+ $school = 'arkan';
+ }
+ $grade = max(1, min(9, $grade));
+ db()->prepare(
+ 'INSERT INTO character_spells (character_id, spell_id, name, school, grade, note)
+ VALUES (?, ?, ?, ?, ?, ?)
+ ON DUPLICATE KEY UPDATE grade = VALUES(grade), note = VALUES(note)'
+ )->execute([$characterId, $spellId, shorten($name, 120), $school, $grade, shorten($note, 255)]);
+}
+
+function character_spell_delete(int $characterId, int $id): void
+{
+ db()->prepare('DELETE FROM character_spells WHERE id = ? AND character_id = ?')->execute([$id, $characterId]);
+}
+
+/* -------------------------------------------------------------- Inventar */
+
+function character_items(int $characterId): array
+{
+ $stmt = db()->prepare('SELECT * FROM character_items WHERE character_id = ? ORDER BY category, sort_order, name');
+ $stmt->execute([$characterId]);
+ return $stmt->fetchAll();
+}
+
+function character_item_add(int $characterId, array $d): void
+{
+ $name = trim((string) ($d['name'] ?? ''));
+ if ($name === '') {
+ return;
+ }
+ $category = (string) ($d['category'] ?? 'Ausrüstung');
+ if (!in_array($category, WS_ITEM_CATEGORIES, true)) {
+ $category = 'Sonstiges';
+ }
+ db()->prepare(
+ 'INSERT INTO character_items (character_id, name, qty, category, weight, value, equipped, note)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
+ )->execute([
+ $characterId,
+ shorten($name, 120),
+ max(1, (int) ($d['qty'] ?? 1)),
+ $category,
+ shorten((string) ($d['weight'] ?? ''), 40),
+ shorten((string) ($d['value'] ?? ''), 40),
+ !empty($d['equipped']) ? 1 : 0,
+ shorten((string) ($d['note'] ?? ''), 255),
+ ]);
+}
+
+function character_item_delete(int $characterId, int $id): void
+{
+ db()->prepare('DELETE FROM character_items WHERE id = ? AND character_id = ?')->execute([$id, $characterId]);
+}
+
+function character_item_toggle(int $characterId, int $id): void
+{
+ db()->prepare('UPDATE character_items SET equipped = 1 - equipped WHERE id = ? AND character_id = ?')
+ ->execute([$id, $characterId]);
+}
+
+/* ------------------------------------------------- Waffen & Rüstungen */
+
+function weapons_catalog(): array
+{
+ return db()->query('SELECT * FROM weapons ORDER BY sort_order, name')->fetchAll();
+}
+
+function armors_catalog(): array
+{
+ return db()->query('SELECT * FROM armors ORDER BY sort_order, name')->fetchAll();
+}
+
+function weapon_catalog_find(int $id): ?array
+{
+ $stmt = db()->prepare('SELECT * FROM weapons WHERE id = ? LIMIT 1');
+ $stmt->execute([$id]);
+ return $stmt->fetch() ?: null;
+}
+
+function armor_catalog_find(int $id): ?array
+{
+ $stmt = db()->prepare('SELECT * FROM armors WHERE id = ? LIMIT 1');
+ $stmt->execute([$id]);
+ return $stmt->fetch() ?: null;
+}
+
+function character_weapons(int $characterId): array
+{
+ $stmt = db()->prepare('SELECT * FROM character_weapons WHERE character_id = ? ORDER BY sort_order, name');
+ $stmt->execute([$characterId]);
+ return $stmt->fetchAll();
+}
+
+function character_armors(int $characterId): array
+{
+ $stmt = db()->prepare('SELECT * FROM character_armors WHERE character_id = ? ORDER BY sort_order, name');
+ $stmt->execute([$characterId]);
+ return $stmt->fetchAll();
+}
+
+/** Waffe hinzufügen: aus dem Katalog (Werte übernehmen) oder frei eingetragen. */
+function character_weapon_add(int $characterId, int $weaponId, array $d = []): void
+{
+ $name = trim((string) ($d['name'] ?? ''));
+ $damage = trim((string) ($d['damage'] ?? ''));
+ $bonus = (int) ($d['attack_bonus'] ?? 0);
+ $category = (string) ($d['category'] ?? 'Nahkampf');
+
+ if ($weaponId > 0 && ($weapon = weapon_catalog_find($weaponId)) !== null) {
+ $name = $name !== '' ? $name : (string) $weapon['name'];
+ $damage = $damage !== '' ? $damage : (string) $weapon['damage'];
+ $category = $category !== '' ? $category : (string) $weapon['category'];
+ $bonus = $bonus !== 0 ? $bonus : (int) $weapon['attack_bonus'];
+ }
+ if ($name === '') {
+ return;
+ }
+ if (!in_array($category, ['Nahkampf', 'Fernkampf'], true)) {
+ $category = 'Nahkampf';
+ }
+ db()->prepare(
+ 'INSERT INTO character_weapons (character_id, weapon_id, name, damage, attack_bonus, category, note, equipped)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
+ )->execute([
+ $characterId,
+ $weaponId > 0 ? $weaponId : null,
+ shorten($name, 80),
+ shorten($damage === '' ? '1W6' : $damage, 20),
+ max(-10, min(10, $bonus)),
+ $category,
+ shorten((string) ($d['note'] ?? ''), 255),
+ !empty($d['equipped']) ? 1 : 0,
+ ]);
+}
+
+function character_weapon_update(int $characterId, int $id, array $d): void
+{
+ $name = trim((string) ($d['name'] ?? ''));
+ if ($name === '') {
+ return;
+ }
+ $category = (string) ($d['category'] ?? 'Nahkampf');
+ if (!in_array($category, ['Nahkampf', 'Fernkampf'], true)) {
+ $category = 'Nahkampf';
+ }
+ db()->prepare(
+ 'UPDATE character_weapons SET name = ?, damage = ?, attack_bonus = ?, category = ?, note = ?, equipped = ?
+ WHERE id = ? AND character_id = ?'
+ )->execute([
+ shorten($name, 80),
+ shorten((string) ($d['damage'] ?? ''), 20),
+ max(-10, min(10, (int) ($d['attack_bonus'] ?? 0))),
+ $category,
+ shorten((string) ($d['note'] ?? ''), 255),
+ !empty($d['equipped']) ? 1 : 0,
+ $id,
+ $characterId,
+ ]);
+}
+
+function character_weapon_delete(int $characterId, int $id): void
+{
+ db()->prepare('DELETE FROM character_weapons WHERE id = ? AND character_id = ?')->execute([$id, $characterId]);
+}
+
+function character_weapon_toggle(int $characterId, int $id): void
+{
+ db()->prepare('UPDATE character_weapons SET equipped = 1 - equipped WHERE id = ? AND character_id = ?')
+ ->execute([$id, $characterId]);
+}
+
+function character_armor_add(int $characterId, int $armorId, array $d = []): void
+{
+ $name = trim((string) ($d['name'] ?? ''));
+ $bonus = isset($d['ac_bonus']) && $d['ac_bonus'] !== '' ? (int) $d['ac_bonus'] : null;
+ $kind = (string) ($d['kind'] ?? 'Rüstung');
+
+ if ($armorId > 0 && ($armor = armor_catalog_find($armorId)) !== null) {
+ $name = $name !== '' ? $name : (string) $armor['name'];
+ $bonus = $bonus !== null ? $bonus : (int) $armor['ac_bonus'];
+ $kind = $kind !== '' ? $kind : (string) $armor['kind'];
+ }
+ if ($name === '') {
+ return;
+ }
+ if (!in_array($kind, ['Rüstung', 'Schild'], true)) {
+ $kind = 'Rüstung';
+ }
+ db()->prepare(
+ 'INSERT INTO character_armors (character_id, armor_id, name, ac_bonus, kind, note, equipped)
+ VALUES (?, ?, ?, ?, ?, ?, ?)'
+ )->execute([
+ $characterId,
+ $armorId > 0 ? $armorId : null,
+ shorten($name, 80),
+ max(-5, min(15, $bonus ?? 0)),
+ $kind,
+ shorten((string) ($d['note'] ?? ''), 255),
+ !empty($d['equipped']) ? 1 : 0,
+ ]);
+}
+
+function character_armor_update(int $characterId, int $id, array $d): void
+{
+ $name = trim((string) ($d['name'] ?? ''));
+ if ($name === '') {
+ return;
+ }
+ $kind = (string) ($d['kind'] ?? 'Rüstung');
+ if (!in_array($kind, ['Rüstung', 'Schild'], true)) {
+ $kind = 'Rüstung';
+ }
+ db()->prepare(
+ 'UPDATE character_armors SET name = ?, ac_bonus = ?, kind = ?, note = ?, equipped = ?
+ WHERE id = ? AND character_id = ?'
+ )->execute([
+ shorten($name, 80),
+ max(-5, min(15, (int) ($d['ac_bonus'] ?? 0))),
+ $kind,
+ shorten((string) ($d['note'] ?? ''), 255),
+ !empty($d['equipped']) ? 1 : 0,
+ $id,
+ $characterId,
+ ]);
+}
+
+function character_armor_delete(int $characterId, int $id): void
+{
+ db()->prepare('DELETE FROM character_armors WHERE id = ? AND character_id = ?')->execute([$id, $characterId]);
+}
+
+function character_armor_toggle(int $characterId, int $id): void
+{
+ db()->prepare('UPDATE character_armors SET equipped = 1 - equipped WHERE id = ? AND character_id = ?')
+ ->execute([$id, $characterId]);
+}
+
+function character_skill_update(int $characterId, int $id, int $bonus, string $note): void
+{
+ db()->prepare('UPDATE character_skills SET bonus = ?, note = ? WHERE id = ? AND character_id = ?')
+ ->execute([max(-10, min(30, $bonus)), shorten($note, 255), $id, $characterId]);
+}
+
+/**
+ * Fertigkeiten nach Gruppen des Charakterbogens sortieren.
+ *
+ * @param list $skills
+ * @return array>
+ */
+function skills_grouped(array $skills): array
+{
+ $groups = [];
+ foreach (WS_SKILL_GROUPS as $group) {
+ $groups[$group] = [];
+ }
+ foreach ($skills as $skill) {
+ $group = trim((string) ($skill['category'] ?? ''));
+ if ($group === '') {
+ $group = 'Sonstiges';
+ }
+ $groups[$group][] = $skill;
+ }
+ // Feste Reihenfolge des Charakterbogens, unbekannte Gruppen danach.
+ $ordered = [];
+ $sequence = WS_SKILL_GROUPS;
+ $sequence[] = 'Sonstiges';
+ foreach ($sequence as $group) {
+ if (empty($groups[$group])) {
+ continue;
+ }
+ $rows = $groups[$group];
+ usort($rows, static fn ($a, $b) => strcasecmp((string) $a['name'], (string) $b['name']));
+ $ordered[$group] = $rows;
+ unset($groups[$group]);
+ }
+ foreach ($groups as $group => $rows) {
+ if ($rows === []) {
+ continue;
+ }
+ usort($rows, static fn ($a, $b) => strcasecmp((string) $a['name'], (string) $b['name']));
+ $ordered[$group] = $rows;
+ }
+ return $ordered;
+}
+
+/** Attributsbonus (MOD) einer Fertigkeit für einen Charakter. */
+function skill_attribute_modifier(array $character, array $skill): ?int
+{
+ $attribute = strtolower(trim((string) ($skill['attribute'] ?? '')));
+ if ($attribute === '') {
+ return null;
+ }
+ return attribute_bonus((int) ($character['attr_' . $attribute] ?? 10));
+}
diff --git a/westreiche_website/app/config.example.php b/westreiche_website/app/config.example.php
new file mode 100644
index 0000000..baeeac5
--- /dev/null
+++ b/westreiche_website/app/config.example.php
@@ -0,0 +1,40 @@
+ [
+ 'host' => 'DB_HOST',
+ 'port' => 3306,
+ 'name' => 'DB_NAME',
+ 'user' => 'DB_USER',
+ 'password' => 'DB_PASSWORD',
+ 'charset' => 'utf8mb4',
+ ],
+ 'mail' => [
+ // Leer = kein Versand (Einladungslinks werden nur angezeigt).
+ 'host' => 'MAIL_HOST',
+ 'port' => 587,
+ // 'tls' = STARTTLS (587), 'ssl' = implizites TLS (465)
+ 'secure' => 'tls',
+ 'user' => 'MAIL_USER',
+ 'password' => 'MAIL_PASSWORD',
+ 'from' => 'MAIL_FROM',
+ 'from_name' => 'MAIL_FROM_NAME',
+ 'timeout' => 15,
+ ],
+ 'app' => [
+ // Leer, wenn die App direkt im Zielverzeichnis liegt; sonst z. B. '/westreiche_website'.
+ 'base_path' => '',
+ 'public_url' => 'https://zauberturm.de',
+ 'storage_path' => dirname(__DIR__) . '/storage',
+ 'install_token' => 'wird-beim-deployment-erzeugt',
+ 'session_idle_seconds' => 30 * 86400,
+ 'session_absolute_seconds' => 90 * 86400,
+ 'remember_seconds' => 90 * 86400,
+ 'login_window_seconds' => 900,
+ 'login_max_per_user' => 5,
+ 'login_max_per_ip' => 15,
+ ],
+];
diff --git a/westreiche_website/app/db.php b/westreiche_website/app/db.php
new file mode 100644
index 0000000..2f4b927
--- /dev/null
+++ b/westreiche_website/app/db.php
@@ -0,0 +1,33 @@
+ PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::ATTR_EMULATE_PREPARES => false,
+ PDO::ATTR_STRINGIFY_FETCHES => false,
+ ]);
+ $pdo->exec("SET time_zone = '+00:00'");
+ if (function_exists('ws_migrations_apply')) {
+ ws_migrations_apply($pdo);
+ }
+ return $pdo;
+}
diff --git a/westreiche_website/app/invite.php b/westreiche_website/app/invite.php
new file mode 100644
index 0000000..c71c9b2
--- /dev/null
+++ b/westreiche_website/app/invite.php
@@ -0,0 +1,123 @@
+prepare('DELETE FROM user_invites WHERE user_id = ?')->execute([$userId]);
+ db()->prepare(
+ 'INSERT INTO user_invites (user_id, token_hash, created_by, created_at, expires_at)
+ VALUES (?, ?, ?, ?, ?)'
+ )->execute([$userId, hash('sha256', $token), $createdBy, utc_now(), $expiresAt]);
+
+ return ['token' => $token, 'url' => invite_url($token), 'expires_at' => $expiresAt];
+}
+
+/** Sucht eine offene, noch gültige Einladung zum Token. */
+function invite_find(string $token): ?array
+{
+ if (preg_match('/^[a-f0-9]{64}$/', $token) !== 1) {
+ return null;
+ }
+ $stmt = db()->prepare(
+ 'SELECT i.*, u.username, u.email, u.display_name, u.status
+ FROM user_invites i JOIN users u ON u.id = i.user_id
+ WHERE i.token_hash = ? AND i.used_at IS NULL AND i.expires_at >= ? LIMIT 1'
+ );
+ $stmt->execute([hash('sha256', $token), utc_now()]);
+ $row = $stmt->fetch();
+ if (!$row) {
+ return null;
+ }
+ $row['id'] = (int) $row['id'];
+ $row['user_id'] = (int) $row['user_id'];
+ return $row;
+}
+
+function invite_active_for_user(int $userId): ?array
+{
+ $stmt = db()->prepare(
+ 'SELECT * FROM user_invites WHERE user_id = ? AND used_at IS NULL AND expires_at >= ?
+ ORDER BY id DESC LIMIT 1'
+ );
+ $stmt->execute([$userId, utc_now()]);
+ return $stmt->fetch() ?: null;
+}
+
+function invite_redeem(string $token, string $password): void
+{
+ $invite = invite_find($token);
+ if ($invite === null) {
+ throw new RuntimeException('invalid');
+ }
+ $pdo = db();
+ $pdo->beginTransaction();
+ try {
+ $pdo->prepare(
+ 'UPDATE users SET password_hash = ?, password_changed_at = ?, must_change_password = 0,
+ auth_epoch = auth_epoch + 1, updated_at = ? WHERE id = ?'
+ )->execute([hash_password($password), utc_now(), utc_now(), (int) $invite['user_id']]);
+ $pdo->prepare('UPDATE user_invites SET used_at = ? WHERE id = ?')
+ ->execute([utc_now(), (int) $invite['id']]);
+ $pdo->commit();
+ } catch (Throwable $error) {
+ $pdo->rollBack();
+ throw $error;
+ }
+}
+
+/**
+ * Setzt das Passwort zurück, sperrt alte Sitzungen und erzeugt einen neuen
+ * Einladungslink (Rückgabe: URL zum Weitergeben).
+ */
+function invite_provision(int $userId, ?int $createdBy): array
+{
+ $user = auth_user_by_id($userId);
+ if (!$user) {
+ throw new RuntimeException('Benutzer nicht gefunden.');
+ }
+
+ $pdo = db();
+ $pdo->beginTransaction();
+ try {
+ $pdo->prepare(
+ 'UPDATE users SET password_hash = ?, password_changed_at = ?, must_change_password = 1,
+ auth_epoch = auth_epoch + 1, updated_at = ? WHERE id = ?'
+ )->execute([hash_password(bin2hex(random_bytes(24))), utc_now(), utc_now(), $userId]);
+ $pdo->prepare('DELETE FROM auth_tokens WHERE user_id = ?')->execute([$userId]);
+ $pdo->commit();
+ } catch (Throwable $error) {
+ $pdo->rollBack();
+ throw $error;
+ }
+
+ return invite_create($userId, $createdBy);
+}
diff --git a/westreiche_website/app/mailer.php b/westreiche_website/app/mailer.php
new file mode 100644
index 0000000..b8d57a6
--- /dev/null
+++ b/westreiche_website/app/mailer.php
@@ -0,0 +1,393 @@
+ */
+ private array $features = [];
+
+ private string $lastError = '';
+
+ public function __construct(
+ private string $host,
+ private int $port,
+ private string $secure,
+ private float $timeout = 15.0,
+ ) {
+ }
+
+ public function connect(): void
+ {
+ $socket = $this->open($this->host);
+ if ($socket === false) {
+ // Manche Netze haben kein IPv6, der Name liefert aber eine AAAA-Adresse:
+ // zweiter Versuch über die IPv4-Adresse, Zertifikat bleibt an den Namen gebunden.
+ $ipv4 = gethostbyname($this->host);
+ if ($ipv4 !== $this->host && filter_var($ipv4, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) {
+ $socket = $this->open($ipv4);
+ }
+ }
+ if ($socket === false) {
+ throw new RuntimeException(sprintf('SMTP-Verbindung zu %s:%d fehlgeschlagen (%s)', $this->host, $this->port, $this->lastError !== '' ? $this->lastError : 'Grund unbekannt'));
+ }
+ stream_set_timeout($socket, (int) max(1, (int) ceil($this->timeout)));
+ $this->socket = $socket;
+ $this->expect(220);
+ $this->ehlo();
+
+ if ($this->secure === 'tls') {
+ if (!array_key_exists('starttls', $this->features)) {
+ throw new RuntimeException('Server bietet kein STARTTLS an.');
+ }
+ $this->cmd('STARTTLS', 220);
+ $ok = @stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+ if ($ok !== true) {
+ throw new RuntimeException('TLS-Aushandlung fehlgeschlagen (Zertifikat oder Protokoll).');
+ }
+ $this->ehlo();
+ }
+ }
+
+ public function authenticate(string $user, string $password): void {
+ $mechanisms = strtoupper($this->features['auth'] ?? '');
+ if (str_contains($mechanisms, 'PLAIN')) {
+ $this->cmd('AUTH PLAIN ' . base64_encode("\0" . $user . "\0" . $password), 235);
+ return;
+ }
+ if (str_contains($mechanisms, 'LOGIN')) {
+ $this->cmd('AUTH LOGIN', 334);
+ $this->cmd(base64_encode($user), 334);
+ $this->cmd(base64_encode($password), 235);
+ return;
+ }
+ throw new RuntimeException('Server bietet weder AUTH PLAIN noch AUTH LOGIN an.');
+ }
+
+ public function sendMail(string $from, string $to, string $raw): void
+ {
+ $this->cmd('MAIL FROM:<' . $from . '>', 250);
+ $this->cmd('RCPT TO:<' . $to . '>', 250);
+ $this->cmd('DATA', 354);
+ // Dot-Stuffing nach RFC 5321: eine Zeile, die mit "." beginnt, wird verdoppelt.
+ $stuffed = preg_replace('/^\./m', '..', str_replace(["\r\n", "\r"], "\n", $raw));
+ $this->writeRaw(str_replace("\n", "\r\n", (string) $stuffed) . "\r\n.\r\n");
+ $this->expect(250);
+ }
+
+ /** @return resource */
+ private function context()
+ {
+ return stream_context_create(['ssl' => [
+ 'verify_peer' => true,
+ 'verify_peer_name' => true,
+ 'peer_name' => $this->host,
+ 'SNI_enabled' => true,
+ 'crypto_method' => STREAM_CRYPTO_METHOD_TLS_CLIENT,
+ ]]);
+ }
+
+ /** @return resource|false */
+ private function open(string $target)
+ {
+ $scheme = $this->secure === 'ssl' ? 'ssl' : 'tcp';
+ $errno = 0;
+ $errstr = '';
+ $socket = @stream_socket_client(
+ $scheme . '://' . $target . ':' . $this->port,
+ $errno,
+ $errstr,
+ $this->timeout,
+ STREAM_CLIENT_CONNECT,
+ $this->context()
+ );
+ if ($socket === false) {
+ $this->lastError = $errstr !== '' ? $errstr : 'Fehler ' . $errno;
+ return false;
+ }
+ return $socket;
+ }
+
+ public function quit(): void
+ {
+ if ($this->socket === null) {
+ return;
+ }
+ try {
+ @fwrite($this->socket, "QUIT\r\n");
+ } catch (Throwable) {
+ // Abschluss ist nicht kritisch.
+ }
+ @fclose($this->socket);
+ $this->socket = null;
+ }
+
+ private function ehlo(): void
+ {
+ $name = gethostname();
+ $response = $this->cmd('EHLO ' . ($name !== false && $name !== '' ? $name : 'localhost'), 250);
+ $this->features = [];
+ foreach (array_slice($response, 1) as $line) {
+ $parts = preg_split('/[\s=]+/', trim($line), 2);
+ if (!is_array($parts) || $parts[0] === '') {
+ continue;
+ }
+ $this->features[strtolower($parts[0])] = $parts[1] ?? '';
+ }
+ if (!array_key_exists('auth', $this->features)) {
+ // Manche Server liefern "AUTH=LOGIN PLAIN" – oben bereits normalisiert.
+ $this->features['auth'] = $this->features['auth'] ?? '';
+ }
+ }
+
+ /** @return list Antwortzeilen ohne Statuscode */
+ private function cmd(string $line, int $expected): array
+ {
+ $this->writeRaw($line . "\r\n");
+ return $this->expect($expected);
+ }
+
+ /** @return list */
+ private function expect(int $expected): array
+ {
+ [$code, $lines] = $this->read();
+ if ($code !== $expected) {
+ throw new RuntimeException(sprintf('SMTP-Dialog: Code %d statt %d (%s)', $code, $expected, implode(' ', $lines)));
+ }
+ return $lines;
+ }
+
+ /** @return array{0:int,1:list} */
+ private function read(): array
+ {
+ if ($this->socket === null) {
+ throw new RuntimeException('Keine SMTP-Verbindung.');
+ }
+ $lines = [];
+ while (true) {
+ $line = fgets($this->socket, 2048);
+ if ($line === false) {
+ throw new RuntimeException('SMTP-Antwort blieb aus (Zeitüberschreitung).');
+ }
+ $line = rtrim($line, "\r\n");
+ if (preg_match('/^(\d{3})([ -])(.*)$/', $line, $m) !== 1) {
+ throw new RuntimeException('Unerwartete SMTP-Antwort: ' . substr($line, 0, 80));
+ }
+ $lines[] = $m[3];
+ if ($m[2] === ' ') {
+ return [(int) $m[1], $lines];
+ }
+ }
+ }
+
+ private function writeRaw(string $data): void
+ {
+ if ($this->socket === null) {
+ throw new RuntimeException('Keine SMTP-Verbindung.');
+ }
+ $remaining = $data;
+ while ($remaining !== '') {
+ $written = @fwrite($this->socket, $remaining);
+ if ($written === false || $written === 0) {
+ throw new RuntimeException('Schreiben auf die SMTP-Verbindung fehlgeschlagen.');
+ }
+ $remaining = substr($remaining, $written);
+ }
+ }
+}
+
+/** @return array */
+function mail_settings(): array
+{
+ $mail = config('mail', []);
+ return is_array($mail) ? $mail : [];
+}
+
+/** Ist der Versand eingerichtet und vollständig konfiguriert? */
+function mail_ready(): bool
+{
+ $settings = mail_settings();
+ return trim((string) ($settings['host'] ?? '')) !== ''
+ && trim((string) ($settings['from'] ?? '')) !== ''
+ && trim((string) ($settings['user'] ?? '')) !== ''
+ && (string) ($settings['password'] ?? '') !== '';
+}
+
+function mail_log(string $message): void
+{
+ error_log('Westreiche-Mail: ' . $message);
+}
+
+/** Kodiert einen Header-Wert als RFC-2047-Wort (mit Folding für lange Betreffs). */
+function mail_encode_header(string $value): string
+{
+ if (preg_match('/^[\x20-\x7E]*$/', $value) === 1) {
+ return $value;
+ }
+ $encoded = base64_encode($value);
+ $words = str_split($encoded, 60);
+ return implode("\r\n ", array_map(static fn (string $chunk): string => '=?UTF-8?B?' . $chunk . '?=', $words));
+}
+
+function mail_display_name(string $name): string
+{
+ if ($name === '') {
+ return '';
+ }
+ if (preg_match('/^[\x20-\x7E]+$/', $name) === 1) {
+ return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $name) . '"';
+ }
+ return mail_encode_header($name);
+}
+
+/** Baut die vollständige Nachricht (Header + base64-Textkörper) mit CRLF-Zeilen. */
+function mail_build(string $from, string $fromName, string $to, string $subject, string $text): string
+{
+ $address = (string) substr((string) strrchr($from, '@'), 1);
+ $domain = $address !== '' ? $address : 'zauberturm.de';
+ $name = mail_display_name($fromName);
+
+ $headers = [
+ 'Date: ' . date('r'),
+ 'From: ' . ($name !== '' ? $name . ' <' . $from . '>' : $from),
+ 'To: ' . $to,
+ 'Subject: ' . mail_encode_header($subject),
+ 'Message-ID: <' . bin2hex(random_bytes(12)) . '@' . $domain . '>',
+ 'MIME-Version: 1.0',
+ 'Content-Type: text/plain; charset=UTF-8',
+ 'Content-Transfer-Encoding: base64',
+ 'X-Mailer: Westreiche Charakterverwaltung',
+ ];
+
+ $normalized = str_replace(["\r\n", "\r"], "\n", $text);
+ $body = rtrim(chunk_split(base64_encode($normalized), 76, "\r\n"), "\r\n");
+
+ return implode("\r\n", $headers) . "\r\n\r\n" . $body;
+}
+
+/** Verschickt eine reine Textmail; wirft bei Fehlern RuntimeException. */
+function mail_send(string $to, string $subject, string $text): void
+{
+ if (!mail_ready()) {
+ throw new RuntimeException('Mailversand ist nicht eingerichtet.');
+ }
+ if (filter_var($to, FILTER_VALIDATE_EMAIL) === false) {
+ throw new RuntimeException('Ungültige Empfängeradresse: ' . $to);
+ }
+
+ $settings = mail_settings();
+ $secure = strtolower(trim((string) ($settings['secure'] ?? 'tls')));
+ if (!in_array($secure, ['tls', 'ssl'], true)) {
+ $secure = 'tls';
+ }
+ $port = (int) ($settings['port'] ?? 0);
+ $from = trim((string) $settings['from']);
+
+ $client = new WsSmtp(
+ trim((string) $settings['host']),
+ $port > 0 ? $port : ($secure === 'ssl' ? 465 : 587),
+ $secure,
+ (float) ($settings['timeout'] ?? 15)
+ );
+
+ try {
+ $client->connect();
+ $client->authenticate(trim((string) $settings['user']), (string) $settings['password']);
+ $client->sendMail(
+ $from,
+ $to,
+ mail_build($from, trim((string) ($settings['from_name'] ?? '')), $to, $subject, $text)
+ );
+ } finally {
+ $client->quit();
+ }
+}
+
+/** Text der Einladungsmail (auch für Passwort-Zurücksetzen passend). */
+function mail_invite_text(array $user, array $invite): string
+{
+ $name = trim((string) ($user['display_name'] ?? ''));
+ if ($name === '') {
+ $name = trim((string) ($user['username'] ?? ''));
+ }
+ $salutation = $name !== '' ? 'Hallo ' . $name . ',' : 'Hallo,';
+
+ $base = rtrim((string) config('app.public_url', ''), '/');
+ $path = rtrim((string) config('app.base_path', ''), '/');
+ $start = $base . ($path !== '' && !str_ends_with($base, $path) ? $path : '');
+ $expires = (new DateTimeImmutable((string) $invite['expires_at'], new DateTimeZone('UTC')))
+ ->setTimezone(new DateTimeZone('Europe/Berlin'))
+ ->format('d.m.Y H:i');
+
+ return implode("\n", [
+ $salutation,
+ '',
+ 'für dich gibt es einen Zugang zur Westreiche-Chronik, dem Charakterverwalter',
+ 'unserer Runde: ' . $start . '/',
+ '',
+ 'Bitte vergib dein Passwort über diesen Link – er ist einmal verwendbar und',
+ 'gültig bis ' . $expires . ' Uhr:',
+ '',
+ $invite['url'],
+ '',
+ 'Danach kannst du dich mit deinem Benutzernamen oder dieser Adresse anmelden.',
+ 'Wenn du nichts davon erwartest, ignoriere die Nachricht – ohne den Link',
+ 'lässt sich nichts ändern.',
+ '',
+ 'Mögen die Sterne günstig stehen',
+ 'die Chronik der Zauberturm-Runde',
+ ]);
+}
+
+/**
+ * Verschickt die Einladung, wenn möglich, und liefert den Status für die
+ * Rückmeldung im Admin-Formular.
+ *
+ * @return array{sent:bool, to:string|null, reason:string}
+ */
+function mail_invite_result(array $user, array $invite): array
+{
+ if (!mail_ready()) {
+ return ['sent' => false, 'to' => null, 'reason' => 'not_configured'];
+ }
+ $to = trim((string) ($user['email'] ?? ''));
+ if ($to === '') {
+ return ['sent' => false, 'to' => null, 'reason' => 'no_address'];
+ }
+ try {
+ mail_send($to, 'Dein Zugang zur Westreiche-Chronik', mail_invite_text($user, $invite));
+ return ['sent' => true, 'to' => $to, 'reason' => 'ok'];
+ } catch (Throwable $error) {
+ mail_log('Einladung an ' . $to . ' fehlgeschlagen: ' . $error->getMessage());
+ return ['sent' => false, 'to' => $to, 'reason' => 'error'];
+ }
+}
+
+/** Zusatz für die Flash-Meldung nach dem Erzeugen einer Einladung. */
+function mail_invite_note(array $result): string
+{
+ if (($result['sent'] ?? false) === true) {
+ return ' Einladung per E-Mail an ' . (string) $result['to'] . ' gesendet.';
+ }
+ return match ($result['reason'] ?? '') {
+ 'no_address' => ' Keine E-Mail-Adresse hinterlegt – Link bitte kopieren und weitergeben.',
+ 'error' => ' E-Mail-Versand fehlgeschlagen – Link bitte kopieren und weitergeben.',
+ default => '',
+ };
+}
diff --git a/westreiche_website/app/migrations.php b/westreiche_website/app/migrations.php
new file mode 100644
index 0000000..0b34a34
--- /dev/null
+++ b/westreiche_website/app/migrations.php
@@ -0,0 +1,57 @@
+ [
+ 'ALTER TABLE spells ADD COLUMN IF NOT EXISTS body LONGTEXT NULL AFTER summary',
+ ],
+];
+
+function ws_migrations_apply(PDO $pdo): void
+{
+ static $applied = false;
+ if ($applied) {
+ return;
+ }
+ $applied = true;
+
+ try {
+ $pdo->exec(
+ 'CREATE TABLE IF NOT EXISTS schema_migrations (
+ version INT UNSIGNED NOT NULL,
+ applied_at DATETIME NOT NULL,
+ PRIMARY KEY (version)
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci'
+ );
+ $done = array_map('intval', $pdo->query('SELECT version FROM schema_migrations')->fetchAll(PDO::FETCH_COLUMN));
+ foreach (WS_MIGRATIONS as $version => $statements) {
+ if (in_array((int) $version, $done, true)) {
+ continue;
+ }
+ foreach ((array) $statements as $sql) {
+ $pdo->exec($sql);
+ }
+ $pdo->prepare('INSERT INTO schema_migrations (version, applied_at) VALUES (?, ?)')
+ ->execute([(int) $version, gmdate('Y-m-d H:i:s')]);
+ }
+ } catch (Throwable $error) {
+ // Migration darf die Seite nicht lahmlegen; Fehler landet im Log.
+ error_log('Westreiche-Migration: ' . $error->getMessage());
+ }
+}
diff --git a/westreiche_website/app/pages.php b/westreiche_website/app/pages.php
new file mode 100644
index 0000000..fc477b1
--- /dev/null
+++ b/westreiche_website/app/pages.php
@@ -0,0 +1,838 @@
+ characters_all($user)], 'Meine Charaktere');
+ return;
+ }
+ if ($path === '/characters/new') {
+ page_character_new($method, $user);
+ return;
+ }
+ if (preg_match('#^/characters/(\d+)$#', $path, $m) === 1) {
+ page_character_sheet((int) $m[1], $user);
+ return;
+ }
+ if (preg_match('#^/characters/(\d+)/edit$#', $path, $m) === 1) {
+ page_character_edit($method, (int) $m[1], $user);
+ return;
+ }
+ if (preg_match('#^/characters/(\d+)/pdf$#', $path, $m) === 1) {
+ page_character_pdf((int) $m[1], $user);
+ return;
+ }
+ if (preg_match('#^/characters/(\d+)/portrait(/delete)?$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ if (($m[2] ?? '') === '/delete') {
+ portrait_remove((int) $character['id']);
+ flash('info', 'Porträt entfernt – es gilt wieder das Platzhalterbild.');
+ } else {
+ $result = portrait_upload((int) $character['id'], $_FILES['portrait'] ?? []);
+ $result['ok']
+ ? flash('success', 'Porträt gespeichert.')
+ : flash('error', $result['error']);
+ }
+ redirect('/characters/' . $character['id'] . '/edit#portraet');
+ }
+ if (preg_match('#^/characters/(\d+)/delete$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ if (!auth_can_manage($user) && (int) $character['user_id'] !== (int) $user['id']) {
+ abort_page(403, 'Kein Zugriff.');
+ }
+ portrait_delete_file((string) $character['portrait']);
+ character_delete((int) $character['id']);
+ flash('info', '„' . $character['name'] . '“ wurde gelöscht.');
+ redirect('/');
+ }
+ if (preg_match('#^/characters/(\d+)/skills/(add|\d+/delete)$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ if ($m[2] === 'add') {
+ $skillId = post_int('skill_id', 0);
+ character_skill_add(
+ (int) $character['id'],
+ $skillId > 0 ? $skillId : null,
+ post_string('name'),
+ post_int('bonus', 0),
+ post_string('note')
+ );
+ flash('success', 'Fertigkeit eingetragen.');
+ } else {
+ character_skill_delete((int) $character['id'], (int) explode('/', $m[2])[0]);
+ flash('info', 'Fertigkeit entfernt.');
+ }
+ redirect('/characters/' . $character['id'] . '/edit#fertigkeiten');
+ }
+ if (preg_match('#^/characters/(\d+)/skills/reset$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ $count = character_reset_skills((int) $character['id'], post_string('force') === '1');
+ flash('success', $count . ' Fertigkeitswerte auf den Attributsstand gesetzt.');
+ redirect('/characters/' . $character['id'] . '/edit#fertigkeiten');
+ }
+ if (preg_match('#^/characters/(\d+)/skills/(\d+)$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ character_skill_update((int) $character['id'], (int) $m[2], post_int('bonus', 0), post_string('note'));
+ flash('success', 'Fertigkeit gespeichert.');
+ redirect('/characters/' . $character['id'] . '/edit#fertigkeiten');
+ }
+ if (preg_match('#^/characters/(\d+)/weapons/(add|\d+(?:/(?:delete|toggle))?)$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ $action = $m[2];
+ if ($action === 'add') {
+ character_weapon_add((int) $character['id'], post_int('weapon_id', 0), [
+ 'name' => post_string('name'),
+ 'damage' => post_string('damage'),
+ 'attack_bonus' => post_int('attack_bonus', 0),
+ 'category' => post_string('category', 'Nahkampf'),
+ 'note' => post_string('note'),
+ 'equipped' => '1',
+ ]);
+ flash('success', 'Waffe hinzugefügt.');
+ } else {
+ $parts = explode('/', $action);
+ if (isset($parts[1]) && $parts[1] === 'delete') {
+ character_weapon_delete((int) $character['id'], (int) $parts[0]);
+ flash('info', 'Waffe entfernt.');
+ } elseif (isset($parts[1]) && $parts[1] === 'toggle') {
+ character_weapon_toggle((int) $character['id'], (int) $parts[0]);
+ flash('info', 'Waffe in/aus der Hand genommen.');
+ } else {
+ character_weapon_update((int) $character['id'], (int) $parts[0], [
+ 'name' => post_string('name'),
+ 'damage' => post_string('damage'),
+ 'attack_bonus' => post_int('attack_bonus', 0),
+ 'category' => post_string('category', 'Nahkampf'),
+ 'note' => post_string('note'),
+ 'equipped' => post_string('equipped') === '1',
+ ]);
+ flash('success', 'Waffe gespeichert.');
+ }
+ }
+ redirect('/characters/' . $character['id'] . '/edit#bewaffnung');
+ }
+ if (preg_match('#^/characters/(\d+)/armors/(add|\d+(?:/(?:delete|toggle))?)$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ $action = $m[2];
+ if ($action === 'add') {
+ character_armor_add((int) $character['id'], post_int('armor_id', 0), [
+ 'name' => post_string('name'),
+ 'ac_bonus' => post_string('ac_bonus'),
+ 'kind' => post_string('kind', 'Rüstung'),
+ 'note' => post_string('note'),
+ 'equipped' => '1',
+ ]);
+ flash('success', 'Rüstungsteil hinzugefügt.');
+ } else {
+ $parts = explode('/', $action);
+ if (isset($parts[1]) && $parts[1] === 'delete') {
+ character_armor_delete((int) $character['id'], (int) $parts[0]);
+ flash('info', 'Rüstungsteil entfernt.');
+ } elseif (isset($parts[1]) && $parts[1] === 'toggle') {
+ character_armor_toggle((int) $character['id'], (int) $parts[0]);
+ flash('info', 'Angelegt/abgelegt.');
+ } else {
+ character_armor_update((int) $character['id'], (int) $parts[0], [
+ 'name' => post_string('name'),
+ 'ac_bonus' => post_int('ac_bonus', 0),
+ 'kind' => post_string('kind', 'Rüstung'),
+ 'note' => post_string('note'),
+ 'equipped' => post_string('equipped') === '1',
+ ]);
+ flash('success', 'Rüstungsteil gespeichert.');
+ }
+ }
+ redirect('/characters/' . $character['id'] . '/edit#ruestung');
+ }
+ if (preg_match('#^/characters/(\d+)/spells/(add|\d+/delete)$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ if ($m[2] === 'add') {
+ $spellId = post_int('spell_id', 0);
+ character_spell_add(
+ (int) $character['id'],
+ $spellId > 0 ? $spellId : null,
+ post_string('name'),
+ post_string('school', 'arkan'),
+ post_int('grade', 1),
+ post_string('note')
+ );
+ flash('success', 'Zauber/Liturgie eingetragen.');
+ } else {
+ character_spell_delete((int) $character['id'], (int) explode('/', $m[2])[0]);
+ flash('info', 'Zauber entfernt.');
+ }
+ redirect('/characters/' . $character['id'] . '/edit#zauber');
+ }
+ if (preg_match('#^/characters/(\d+)/items/(add|\d+/(?:delete|toggle))$#', $path, $m) === 1) {
+ require_post();
+ $character = character_require((int) $m[1], $user);
+ if ($m[2] === 'add') {
+ character_item_add((int) $character['id'], [
+ 'name' => post_string('name'),
+ 'qty' => post_int('qty', 1),
+ 'category' => post_string('category', 'Ausrüstung'),
+ 'weight' => post_string('weight'),
+ 'value' => post_string('value'),
+ 'equipped' => post_string('equipped') === '1',
+ 'note' => post_string('note'),
+ ]);
+ flash('success', 'Gegenstand eingetragen.');
+ } else {
+ [$id, $action] = explode('/', $m[2]);
+ if ($action === 'delete') {
+ character_item_delete((int) $character['id'], (int) $id);
+ flash('info', 'Gegenstand entfernt.');
+ } else {
+ character_item_toggle((int) $character['id'], (int) $id);
+ flash('info', 'Ausgerüstet-Status umgeschaltet.');
+ }
+ }
+ redirect('/characters/' . $character['id'] . '/edit#inventar');
+ }
+
+ /* ------------------------------------------------------------ Admin */
+ if ($path === '/admin/users') {
+ page_admin_users($user);
+ return;
+ }
+ if ($path === '/admin/users/new') {
+ page_admin_user_new($method, $user);
+ return;
+ }
+ if (preg_match('#^/admin/users/(\d+)$#', $path, $m) === 1) {
+ page_admin_user_edit($method, (int) $m[1], $user);
+ return;
+ }
+ if (preg_match('#^/admin/users/(\d+)/invite$#', $path, $m) === 1) {
+ require_post();
+ auth_require_admin();
+ $invite = invite_provision((int) $m[1], (int) $user['id']);
+ $invitee = auth_user_by_id((int) $m[1]);
+ $mail = $invitee !== null
+ ? mail_invite_result($invitee, $invite)
+ : ['sent' => false, 'to' => null, 'reason' => ''];
+ $_SESSION['last_invite'] = [
+ 'user_id' => (int) $m[1],
+ 'url' => $invite['url'],
+ 'expires_at' => $invite['expires_at'],
+ 'sent' => (bool) $mail['sent'],
+ 'to' => $mail['to'],
+ ];
+ flash('success', 'Neuer Einladungslink erzeugt – das alte Passwort ist ungültig.' . mail_invite_note($mail));
+ redirect('/admin/users/' . (int) $m[1]);
+ }
+ if (preg_match('#^/admin/users/(\d+)/delete$#', $path, $m) === 1) {
+ require_post();
+ $admin = auth_require_admin();
+ $target = (int) $m[1];
+ if ($target === (int) $admin['id']) {
+ flash('error', 'Das eigene Konto kann nicht gelöscht werden.');
+ redirect('/admin/users');
+ }
+ db()->prepare('DELETE FROM users WHERE id = ?')->execute([$target]);
+ flash('info', 'Konto gelöscht.');
+ redirect('/admin/users');
+ }
+ if ($path === '/admin/skills') {
+ page_admin_skills($method, $user);
+ return;
+ }
+ if (preg_match('#^/admin/skills/(\d+)/delete$#', $path, $m) === 1) {
+ require_post();
+ auth_require_admin();
+ skills_catalog_delete((int) $m[1]);
+ flash('info', 'Fertigkeit aus dem Katalog entfernt.');
+ redirect('/admin/skills');
+ }
+ if ($path === '/admin/equipment') {
+ render_page('admin_equipment', [
+ 'weapons' => weapons_catalog(),
+ 'armors' => armors_catalog(),
+ ], 'Waffen & Rüstungen');
+ return;
+ }
+ if ($path === '/admin/spells') {
+ page_admin_spells($user);
+ return;
+ }
+
+ abort_page(404, 'Diese Seite gibt es nicht.');
+}
+
+/* ----------------------------------------------------------------- Login */
+
+function page_login(string $method): void
+{
+ $error = '';
+ $identifier = '';
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } else {
+ $identifier = post_string('identifier');
+ $password = post_string('password');
+ try {
+ $user = auth_verify_login($identifier, $password);
+ auth_login($user, post_string('remember') === '1');
+ redirect(safe_next(post_string('next')));
+ } catch (RuntimeException $e) {
+ $error = match ($e->getMessage()) {
+ 'locked' => 'Zu viele Fehlversuche. Bitte in 15 Minuten erneut versuchen.',
+ 'disabled' => 'Dieses Konto ist deaktiviert. Bitte den Spielleiter fragen.',
+ default => 'Benutzername bzw. E-Mail oder Passwort ist falsch.',
+ };
+ }
+ }
+ }
+ render_standalone('login', [
+ 'error' => $error,
+ 'identifier' => $identifier,
+ 'next' => query_string('next'),
+ ], 'Anmelden');
+}
+
+function page_invite(string $method, string $token): void
+{
+ $invite = invite_find($token);
+ $error = '';
+ if ($invite === null) {
+ render_standalone('invite', ['invite' => null, 'error' => 'Dieser Einladungslink ist ungültig oder abgelaufen.', 'token' => ''], 'Einladung');
+ return;
+ }
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } else {
+ $password = post_string('password');
+ $repeat = post_string('password_repeat');
+ if (($problem = password_problem($password)) !== '') {
+ $error = $problem;
+ } elseif ($password !== $repeat) {
+ $error = 'Die beiden Passwörter stimmen nicht überein.';
+ } else {
+ invite_redeem($token, $password);
+ $user = auth_user_by_id((int) $invite['user_id']);
+ if ($user !== null) {
+ auth_login($user);
+ }
+ flash('success', 'Willkommen in der Westreiche, ' . $invite['username'] . '!');
+ redirect('/');
+ }
+ }
+ }
+ render_standalone('invite', ['invite' => $invite, 'error' => $error, 'token' => $token], 'Einladung annehmen');
+}
+
+/* ---------------------------------------------------------------- Konto */
+
+function page_account(string $method, array $user): void
+{
+ $error = '';
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } else {
+ $action = post_string('action', 'password');
+ if ($action === 'profile') {
+ $displayName = shorten(post_string('display_name'), 120);
+ $email = shorten(post_string('email'), 190);
+ if ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
+ $error = 'Diese E-Mail-Adresse sieht nicht gültig aus.';
+ } elseif (auth_email_taken($email, (int) $user['id'])) {
+ $error = 'Diese E-Mail-Adresse wird bereits verwendet.';
+ } else {
+ db()->prepare('UPDATE users SET display_name = ?, email = ?, updated_at = ? WHERE id = ?')
+ ->execute([$displayName, $email === '' ? null : $email, utc_now(), (int) $user['id']]);
+ flash('success', 'Profil gespeichert.');
+ redirect('/account');
+ }
+ } else {
+ $current = post_string('current_password');
+ $new = post_string('new_password');
+ $repeat = post_string('new_password_repeat');
+ if (!password_verify($current, (string) $user['password_hash'])) {
+ $error = 'Das aktuelle Passwort stimmt nicht.';
+ } elseif (($problem = password_problem($new)) !== '') {
+ $error = $problem;
+ } elseif ($new !== $repeat) {
+ $error = 'Die beiden neuen Passwörter stimmen nicht überein.';
+ } else {
+ db()->prepare(
+ 'UPDATE users SET password_hash = ?, password_changed_at = ?, must_change_password = 0,
+ auth_epoch = auth_epoch + 1, updated_at = ? WHERE id = ?'
+ )->execute([hash_password($new), utc_now(), utc_now(), (int) $user['id']]);
+ $fresh = auth_user_by_id((int) $user['id']);
+ if ($fresh !== null) {
+ auth_login($fresh);
+ }
+ flash('success', 'Passwort geändert.');
+ redirect('/');
+ }
+ }
+ }
+ }
+ render_page('account', ['error' => $error, 'account' => $user], 'Mein Konto');
+}
+
+/* ------------------------------------------------------------ Charaktere */
+
+function character_form_values(array $source): array
+{
+ $values = [];
+ foreach (array_merge(array_keys(WS_ATTRIBUTES), array_keys(WS_SAVES)) as $field) {
+ $values[$field] = post_int($field, (int) ($source[$field] ?? 10));
+ }
+ $values['name'] = post_string('name', (string) ($source['name'] ?? ''));
+ $values['title'] = post_string('title', (string) ($source['title'] ?? ''));
+ $values['class_name'] = post_string('class_name', (string) ($source['class_name'] ?? 'Kämpfer'));
+ $values['level'] = max(1, min(20, post_int('level', (int) ($source['level'] ?? 1))));
+ $values['xp'] = max(0, post_int('xp', (int) ($source['xp'] ?? 0)));
+ $values['hp_max'] = max(1, post_int('hp_max', (int) ($source['hp_max'] ?? 1)));
+ $values['hp_current'] = post_int('hp_current', (int) ($source['hp_current'] ?? $values['hp_max']));
+ $acRaw = post_string('ac', $source['ac'] === null ? '' : (string) $source['ac']);
+ $values['ac'] = $acRaw === '' ? null : max(-10, min(30, (int) $acRaw));
+ $values['attack_bonus'] = post_int('attack_bonus', (int) ($source['attack_bonus'] ?? 0));
+ $values['gold_coins'] = post_int('gold_coins', (int) ($source['gold_coins'] ?? 0));
+ $values['alignment'] = post_string('alignment', (string) ($source['alignment'] ?? ''));
+ $values['deity'] = post_string('deity', (string) ($source['deity'] ?? ''));
+ $values['age'] = post_string('age', (string) ($source['age'] ?? ''));
+ $values['height'] = post_string('height', (string) ($source['height'] ?? ''));
+ $values['weight'] = post_string('weight', (string) ($source['weight'] ?? ''));
+ $values['appearance'] = post_string('appearance', (string) ($source['appearance'] ?? ''));
+ $values['background'] = post_string('background', (string) ($source['background'] ?? ''));
+ $values['notes'] = post_string('notes', (string) ($source['notes'] ?? ''));
+ $values['status'] = post_string('status', (string) ($source['status'] ?? 'active'));
+ if (!array_key_exists($values['status'], WS_CHARACTER_STATUS)) {
+ $values['status'] = 'active';
+ }
+ if (!in_array($values['class_name'], WS_CLASSES, true)) {
+ $values['class_name'] = 'Kämpfer';
+ }
+ foreach (WS_SAVES as $field => $label) {
+ // Auf GET (Formular anzeigen) gilt der gespeicherte Wert; nur ein
+ // tatsächlich abgeschicktes Feld überschreibt ihn.
+ if (array_key_exists($field, $_POST) && is_string($_POST[$field])) {
+ $raw = trim((string) $_POST[$field]);
+ $values[$field] = $raw === '' ? null : max(-10, min(30, (int) $raw));
+ } else {
+ $stored = $source[$field] ?? null;
+ $values[$field] = ($stored === null || $stored === '') ? null : (int) $stored;
+ }
+ }
+ return $values;
+}
+
+function page_character_new(string $method, array $user): void
+{
+ $error = '';
+ $values = character_form_values(['attr_str' => 14, 'attr_dex' => 12, 'attr_con' => 11, 'attr_int' => 10, 'attr_wis' => 9, 'attr_cha' => 7]);
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } elseif ($values['name'] === '') {
+ $error = 'Der Charakter braucht einen Namen.';
+ } else {
+ // Admin darf Charaktere für andere Konten anlegen.
+ $ownerId = (int) $user['id'];
+ if (auth_can_manage($user) && post_int('user_id', 0) > 0) {
+ $ownerId = post_int('user_id');
+ }
+ $id = character_create($ownerId, $values);
+ // Alles nachziehen, was das Anlegeformular schon kennt (Person,
+ // Notizen). Die Rettungswürfe kommen aus der Klassentabelle und
+ // dürfen nicht von leeren Formularfeldern überschrieben werden.
+ character_update($id, array_merge($values, saving_throws_for($values['class_name'], (int) $values['level'])));
+ flash('success', '„' . $values['name'] . '“ betritt die Westreiche.');
+ redirect('/characters/' . $id . '/edit');
+ }
+ }
+ render_page('character_form', [
+ 'character' => null,
+ 'values' => $values,
+ 'error' => $error,
+ 'owners' => auth_can_manage($user) ? db()->query('SELECT id, username FROM users ORDER BY username')->fetchAll() : [],
+ ], 'Neuer Charakter');
+}
+
+function page_character_edit(string $method, int $id, array $user): void
+{
+ $character = character_require($id, $user);
+ $error = '';
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } else {
+ $values = character_form_values($character);
+ if ($values['name'] === '') {
+ $error = 'Der Charakter braucht einen Namen.';
+ } else {
+ character_update((int) $character['id'], $values);
+ flash('success', 'Charakterbogen gespeichert.');
+ redirect('/characters/' . $character['id'] . '/edit');
+ }
+ }
+ }
+ $character = character_require($id, $user);
+ $armors = character_armors((int) $character['id']);
+ render_page('character_edit', [
+ 'character' => $character,
+ 'weapons' => character_weapons((int) $character['id']),
+ 'armors' => $armors,
+ 'weaponCatalog' => weapons_catalog(),
+ 'armorCatalog' => armors_catalog(),
+ 'acInfo' => armor_class_total($character, $armors),
+ 'skills' => character_skills((int) $character['id']),
+ 'skillCatalog' => skills_catalog(),
+ 'spells' => character_spells((int) $character['id']),
+ 'spellCatalog' => db()->query('SELECT id, name, school, grade FROM spells ORDER BY school DESC, grade, name')->fetchAll(),
+ 'items' => character_items((int) $character['id']),
+ ], 'Bogen bearbeiten');
+}
+
+function page_character_sheet(int $id, array $user): void
+{
+ $character = character_require($id, $user);
+ $armors = character_armors((int) $character['id']);
+ render_page('character_sheet', [
+ 'character' => $character,
+ 'weapons' => character_weapons((int) $character['id']),
+ 'armors' => $armors,
+ 'acInfo' => armor_class_total($character, $armors),
+ 'derived' => character_derived($character),
+ 'skills' => character_skills((int) $character['id']),
+ 'spells' => character_spells((int) $character['id']),
+ 'items' => character_items((int) $character['id']),
+ ], (string) $character['name']);
+}
+
+function page_character_pdf(int $id, array $user): void
+{
+ $character = character_require($id, $user);
+ $armors = character_armors((int) $character['id']);
+ $pdf = character_pdf($character, [
+ 'weapons' => character_weapons((int) $character['id']),
+ 'armors' => $armors,
+ 'ac' => armor_class_total($character, $armors),
+ 'skills' => character_skills((int) $character['id']),
+ 'spells' => character_spells((int) $character['id']),
+ 'items' => character_items((int) $character['id']),
+ ]);
+ $slug = preg_replace('/[^A-Za-z0-9]+/', '-', (string) $character['name']) ?: 'charakter';
+ $slug = trim((string) $slug, '-');
+ header('Content-Type: application/pdf');
+ header('Content-Disposition: attachment; filename="Charakterbogen-' . $slug . '.pdf"');
+ header('Content-Length: ' . strlen($pdf));
+ echo $pdf;
+}
+
+function page_spells_json(): void
+{
+ auth_require_login();
+ $school = query_string('school', 'arkan') === 'klerikal' ? 'klerikal' : 'arkan';
+ $grade = query_int('grade', 0);
+ $rows = spells_search($school, $grade, query_string('q'), 200);
+ header('Content-Type: application/json; charset=utf-8');
+ echo json_encode($rows, JSON_UNESCAPED_UNICODE);
+}
+
+/* ----------------------------------------------------------------- Admin */
+
+function page_admin_users(array $user): void
+{
+ auth_require_admin();
+ render_page('admin_users', [
+ 'users' => db()->query(
+ 'SELECT u.*, (SELECT COUNT(*) FROM characters c WHERE c.user_id = u.id) AS character_count
+ FROM users u ORDER BY u.role, u.username'
+ )->fetchAll(),
+ 'lastInvite' => $_SESSION['last_invite'] ?? null,
+ ], 'Benutzer');
+}
+
+function page_admin_user_new(string $method, array $user): void
+{
+ $admin = auth_require_admin();
+ $error = '';
+ $values = [
+ 'username' => post_string('username'),
+ 'email' => post_string('email'),
+ 'display_name' => post_string('display_name'),
+ 'role' => post_string('role', 'user'),
+ 'password' => '',
+ ];
+ $invite = null;
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } else {
+ $password = post_string('password');
+ $sendInvite = post_string('send_invite') === '1';
+ if ($values['username'] === '') {
+ $error = 'Bitte einen Benutzernamen angeben.';
+ } elseif (mb_strlen($values['username'], 'UTF-8') < 3) {
+ $error = 'Der Benutzername braucht mindestens 3 Zeichen.';
+ } elseif (auth_username_taken($values['username'])) {
+ $error = 'Diesen Benutzernamen gibt es schon.';
+ } elseif ($values['email'] !== '' && !filter_var($values['email'], FILTER_VALIDATE_EMAIL)) {
+ $error = 'Diese E-Mail-Adresse sieht nicht gültig aus.';
+ } elseif ($values['email'] !== '' && auth_email_taken($values['email'])) {
+ $error = 'Diese E-Mail-Adresse wird bereits verwendet.';
+ } elseif (!$sendInvite && ($problem = password_problem($password)) !== '') {
+ $error = $problem;
+ } else {
+ if (!in_array($values['role'], ['admin', 'user'], true)) {
+ $values['role'] = 'user';
+ }
+ $hash = hash_password($sendInvite ? bin2hex(random_bytes(24)) : $password);
+ db()->prepare(
+ 'INSERT INTO users (username, email, display_name, password_hash, role, status,
+ must_change_password, created_by, created_at, updated_at, password_changed_at)
+ VALUES (?, ?, ?, ?, ?, \'active\', ?, ?, ?, ?, ?)'
+ )->execute([
+ $values['username'],
+ $values['email'] === '' ? null : $values['email'],
+ $values['display_name'],
+ $hash,
+ $values['role'],
+ $sendInvite ? 1 : 0,
+ (int) $admin['id'],
+ utc_now(),
+ utc_now(),
+ utc_now(),
+ ]);
+ $newId = (int) db()->lastInsertId();
+ if ($sendInvite) {
+ $created = invite_create($newId, (int) $admin['id']);
+ $mail = mail_invite_result([
+ 'email' => $values['email'],
+ 'username' => $values['username'],
+ 'display_name' => $values['display_name'],
+ ], $created);
+ $_SESSION['last_invite'] = [
+ 'user_id' => $newId,
+ 'url' => $created['url'],
+ 'expires_at' => $created['expires_at'],
+ 'sent' => (bool) $mail['sent'],
+ 'to' => $mail['to'],
+ ];
+ flash('success', 'Konto angelegt – Einladungslink ist bereit.' . mail_invite_note($mail));
+ } else {
+ flash('success', 'Konto für ' . $values['username'] . ' angelegt.');
+ }
+ redirect('/admin/users/' . $newId);
+ }
+ }
+ }
+ render_page('admin_user_form', [
+ 'target' => null,
+ 'values' => $values,
+ 'error' => $error,
+ 'inviteUrl' => $invite,
+ 'lastInvite' => $_SESSION['last_invite'] ?? null,
+ ], 'Neues Konto');
+}
+
+function page_admin_user_edit(string $method, int $id, array $user): void
+{
+ $admin = auth_require_admin();
+ $target = auth_user_by_id($id);
+ if ($target === null) {
+ abort_page(404, 'Dieses Konto gibt es nicht.');
+ }
+ $error = '';
+ $values = [
+ 'username' => post_string('username', (string) $target['username']),
+ 'email' => post_string('email', (string) ($target['email'] ?? '')),
+ 'display_name' => post_string('display_name', (string) $target['display_name']),
+ 'role' => post_string('role', (string) $target['role']),
+ 'status' => post_string('status', (string) $target['status']),
+ 'password' => '',
+ ];
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } else {
+ $password = post_string('password');
+ if ($values['username'] === '') {
+ $error = 'Bitte einen Benutzernamen angeben.';
+ } elseif (auth_username_taken($values['username'], $id)) {
+ $error = 'Diesen Benutzernamen gibt es schon.';
+ } elseif ($values['email'] !== '' && !filter_var($values['email'], FILTER_VALIDATE_EMAIL)) {
+ $error = 'Diese E-Mail-Adresse sieht nicht gültig aus.';
+ } elseif ($values['email'] !== '' && auth_email_taken($values['email'], $id)) {
+ $error = 'Diese E-Mail-Adresse wird bereits verwendet.';
+ } elseif ($password !== '' && ($problem = password_problem($password)) !== '') {
+ $error = $problem;
+ } elseif ((int) $admin['id'] === $id && ($values['role'] !== 'admin' || $values['status'] !== 'active')) {
+ $error = 'Das eigene Konto darf nicht zum Benutzer oder deaktiviert werden.';
+ } else {
+ if (!in_array($values['role'], ['admin', 'user'], true)) {
+ $values['role'] = 'user';
+ }
+ if (!in_array($values['status'], ['active', 'disabled'], true)) {
+ $values['status'] = 'active';
+ }
+ db()->prepare(
+ 'UPDATE users SET username = ?, email = ?, display_name = ?, role = ?, status = ?, updated_at = ? WHERE id = ?'
+ )->execute([
+ $values['username'],
+ $values['email'] === '' ? null : $values['email'],
+ $values['display_name'],
+ $values['role'],
+ $values['status'],
+ utc_now(),
+ $id,
+ ]);
+ if ($password !== '') {
+ db()->prepare(
+ 'UPDATE users SET password_hash = ?, password_changed_at = ?, must_change_password = 0,
+ auth_epoch = auth_epoch + 1 WHERE id = ?'
+ )->execute([hash_password($password), utc_now(), $id]);
+ }
+ flash('success', 'Konto gespeichert.');
+ redirect('/admin/users/' . $id);
+ }
+ }
+ }
+ $invite = invite_active_for_user($id);
+ $last = $_SESSION['last_invite'] ?? null;
+ render_page('admin_user_form', [
+ 'target' => $target,
+ 'values' => $values,
+ 'error' => $error,
+ 'activeInvite' => $invite,
+ 'lastInvite' => is_array($last) && (int) $last['user_id'] === $id ? $last : null,
+ ], 'Konto bearbeiten');
+}
+
+function page_admin_skills(string $method, array $user): void
+{
+ auth_require_admin();
+ $error = '';
+ if ($method === 'POST') {
+ if (!csrf_valid()) {
+ $error = 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.';
+ } else {
+ $name = shorten(post_string('name'), 80);
+ $attribute = post_string('attribute');
+ $category = post_string('category', 'Allgemein');
+ if ($name === '') {
+ $error = 'Bitte einen Namen angeben.';
+ } elseif (!in_array($attribute, ['STR', 'DEX', 'CON', 'INT', 'WIS', 'CHA', ''], true)) {
+ $attribute = '';
+ } else {
+ skills_catalog_add($name, $attribute, $category);
+ flash('success', 'Fertigkeit „' . $name . '“ ergänzt.');
+ redirect('/admin/skills');
+ }
+ }
+ }
+ render_page('admin_skills', [
+ 'skills' => skills_catalog(),
+ 'error' => $error,
+ ], 'Fertigkeiten-Katalog');
+}
+
+function page_admin_spells(array $user): void
+{
+ auth_require_admin();
+ $school = query_string('school', 'arkan') === 'klerikal' ? 'klerikal' : 'arkan';
+ render_page('admin_spells', [
+ 'school' => $school,
+ 'grade' => query_int('grade', 0),
+ 'needle' => query_string('q'),
+ 'spells' => spells_search($school, query_int('grade', 0), query_string('q'), 400),
+ ], 'Zauberkatalog');
+}
diff --git a/westreiche_website/app/pdf.php b/westreiche_website/app/pdf.php
new file mode 100644
index 0000000..36815da
--- /dev/null
+++ b/westreiche_website/app/pdf.php
@@ -0,0 +1,303 @@
+ 'Helvetica',
+ 'F2' => 'Helvetica-Bold',
+ 'F3' => 'Times-Roman',
+ 'F4' => 'Times-Bold',
+ 'F5' => 'Times-Italic',
+ ];
+
+ /** Grobe Zeichenbreite relativ zur Schriftgröße (reicht für Zeilenumbrüche). */
+ private const WIDTH_FACTOR = ['F1' => 0.52, 'F2' => 0.57, 'F3' => 0.47, 'F4' => 0.52, 'F5' => 0.46];
+
+ /** @var list */
+ private array $images = [];
+
+ /** @var list */
+ private array $pages = [];
+ private string $buffer = '';
+ private int $pageCount = 0;
+
+ public function __construct()
+ {
+ $this->addPage();
+ }
+
+ public static function width(): float
+ {
+ return self::PAGE_W;
+ }
+
+ public static function height(): float
+ {
+ return self::PAGE_H;
+ }
+
+ public function currentPage(): int
+ {
+ return $this->pageCount;
+ }
+
+ public function addPage(): void
+ {
+ if ($this->buffer !== '') {
+ $this->pages[] = $this->buffer;
+ }
+ $this->buffer = '';
+ $this->pageCount++;
+ }
+
+ private static function encode(string $text): string
+ {
+ $converted = @iconv('UTF-8', 'CP1252//TRANSLIT', $text);
+ if ($converted === false) {
+ $converted = preg_replace('/[^\x20-\x7e]/', '?', $text) ?? '';
+ }
+ return str_replace(['\\', '(', ')', "\r"], ['\\\\', '\\(', '\\)', ''], $converted);
+ }
+
+ private static function color(array $rgb): string
+ {
+ return sprintf('%.3F %.3F %.3F', $rgb[0], $rgb[1], $rgb[2]);
+ }
+
+ /** @param array{0:float,1:float,2:float} $rgb */
+ public function text(float $x, float $yTop, float $size, string $font, array $rgb, string $text): void
+ {
+ if ($text === '') {
+ return;
+ }
+ $this->buffer .= sprintf(
+ "BT /%s %.2F Tf %s rg 1 0 0 1 %.2F %.2F Tm (%s) Tj ET\n",
+ $font,
+ $size,
+ self::color($rgb),
+ $x,
+ self::PAGE_H - $yTop,
+ self::encode($text)
+ );
+ }
+
+ public function textRight(float $xRight, float $yTop, float $size, string $font, array $rgb, string $text): void
+ {
+ $this->text($xRight - self::textWidth($text, $size, $font), $yTop, $size, $font, $rgb, $text);
+ }
+
+ public function textCenter(float $centerX, float $yTop, float $size, string $font, array $rgb, string $text): void
+ {
+ $this->text($centerX - self::textWidth($text, $size, $font) / 2, $yTop, $size, $font, $rgb, $text);
+ }
+
+ public static function textWidth(string $text, float $size, string $font = 'F3'): float
+ {
+ return mb_strlen($text, 'UTF-8') * $size * (self::WIDTH_FACTOR[$font] ?? 0.5);
+ }
+
+ /** @param array{0:float,1:float,2:float} $rgb */
+ public function line(float $x1, float $y1Top, float $x2, float $y2Top, array $rgb, float $lw = 0.6): void
+ {
+ $this->buffer .= sprintf(
+ "q %s RG %.2F w %.2F %.2F m %.2F %.2F l S Q\n",
+ self::color($rgb),
+ $lw,
+ $x1,
+ self::PAGE_H - $y1Top,
+ $x2,
+ self::PAGE_H - $y2Top
+ );
+ }
+
+ /**
+ * @param array{0:float,1:float,2:float}|null $fill
+ * @param array{0:float,1:float,2:float}|null $stroke
+ */
+ public function rect(float $x, float $yTop, float $w, float $h, ?array $fill = null, ?array $stroke = null, float $lw = 0.6): void
+ {
+ $op = '';
+ if ($fill !== null) {
+ $op .= self::color($fill) . ' rg ';
+ }
+ if ($stroke !== null) {
+ $op .= self::color($stroke) . ' RG ' . sprintf('%.2F w ', $lw);
+ }
+ $mode = ($fill !== null && $stroke !== null) ? 'B' : ($fill !== null ? 'f' : 'S');
+ $this->buffer .= sprintf(
+ "q %s%.2F %.2F %.2F %.2F re %s Q\n",
+ $op,
+ $x,
+ self::PAGE_H - $yTop - $h,
+ $w,
+ $h,
+ $mode
+ );
+ }
+
+ /** Zeilenumbruch nach geschätzter Breite. @return list */
+ public static function wrap(string $text, float $size, string $font, float $maxWidth): array
+ {
+ $text = trim(preg_replace('/\s+/u', ' ', $text) ?? '');
+ if ($text === '') {
+ return [];
+ }
+ $lines = [];
+ $current = '';
+ foreach (explode(' ', $text) as $word) {
+ $candidate = $current === '' ? $word : $current . ' ' . $word;
+ if (self::textWidth($candidate, $size, $font) <= $maxWidth || $current === '') {
+ $current = $candidate;
+ continue;
+ }
+ $lines[] = $current;
+ $current = $word;
+ }
+ if ($current !== '') {
+ $lines[] = $current;
+ }
+ return $lines;
+ }
+
+ /**
+ * Bettet ein JPEG ein (DCTDecode, keine Neukodierung nötig).
+ *
+ * @param string $source Dateipfad oder JPEG-Bytes
+ */
+ public function imageJpeg(string $source, float $x, float $yTop, float $w, float $h, bool $isBytes = false): bool
+ {
+ $bytes = $isBytes ? $source : (is_file($source) ? (string) file_get_contents($source) : '');
+ if ($bytes === '' || strncmp($bytes, "\xFF\xD8", 2) !== 0) {
+ return false;
+ }
+ $size = getimagesizefromstring($bytes);
+ if ($size === false) {
+ return false;
+ }
+ $name = 'Im' . (count($this->images) + 1);
+ $this->images[] = ['bytes' => $bytes, 'w' => (int) $size[0], 'h' => (int) $size[1], 'name' => $name, 'object' => 0];
+ $this->buffer .= sprintf(
+ "q %.2F 0 0 %.2F %.2F %.2F cm /%s Do Q\n",
+ $w,
+ $h,
+ $x,
+ self::PAGE_H - $yTop - $h,
+ $name
+ );
+ return true;
+ }
+
+ public function output(): string
+ {
+ $pages = $this->pages;
+ $pages[] = $this->buffer;
+
+ $objects = [];
+ $fontIds = [];
+ $nextFontObj = 3;
+ foreach (self::FONTS as $key => $baseFont) {
+ $fontIds[$key] = $nextFontObj++;
+ $objects[$fontIds[$key]] = sprintf(
+ '<< /Type /Font /Subtype /Type1 /BaseFont /%s /Encoding /WinAnsiEncoding >>',
+ $baseFont
+ );
+ }
+
+ // Bilder als XObjects (JPEG, DCTDecode) – IDs nach den Schriften.
+ $nextImageObj = $nextFontObj;
+ foreach ($this->images as $index => $image) {
+ $objectId = $nextImageObj + $index;
+ $this->images[$index]['object'] = $objectId;
+ $objects[$objectId] = sprintf(
+ "<< /Type /XObject /Subtype /Image /Width %d /Height %d /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length %d >>\nstream\n%s\nendstream",
+ $image['w'],
+ $image['h'],
+ strlen($image['bytes']),
+ $image['bytes']
+ );
+ }
+ $nextFontObj = $nextImageObj + count($this->images);
+
+ $imageRefs = '';
+ foreach ($this->images as $image) {
+ $imageRefs .= sprintf('/%s %d 0 R ', $image['name'], $image['object']);
+ }
+
+ $pageObjStart = $nextFontObj;
+ $pageIds = [];
+ $pageCount = count($pages);
+ for ($i = 0; $i < $pageCount; $i++) {
+ $pageIds[] = $pageObjStart + $i * 2;
+ }
+
+ $fontRefs = '';
+ foreach ($fontIds as $key => $id) {
+ $fontRefs .= sprintf('/%s %d 0 R ', $key, $id);
+ }
+
+ foreach ($pages as $i => $content) {
+ $pageId = $pageIds[$i];
+ $contentId = $pageId + 1;
+ $xObject = $imageRefs !== '' ? '/XObject << ' . $imageRefs . '>> ' : '';
+ $objects[$pageId] = sprintf(
+ '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 %.2F %.2F] /Resources << /Font << %s>> %s>> /Contents %d 0 R >>',
+ self::PAGE_W,
+ self::PAGE_H,
+ $fontRefs,
+ $xObject,
+ $contentId
+ );
+ $objects[$contentId] = sprintf(
+ "<< /Length %d >>\nstream\n%s\nendstream",
+ strlen($content) + 1,
+ $content
+ );
+ }
+
+ $objects[1] = '<< /Type /Catalog /Pages 2 0 R >>';
+ $objects[2] = sprintf(
+ '<< /Type /Pages /Count %d /Kids [%s] >>',
+ $pageCount,
+ implode(' ', array_map(static fn ($id) => $id . ' 0 R', $pageIds))
+ );
+
+ ksort($objects);
+
+ $pdf = "%PDF-1.4\n%\xE2\xE3\xCF\xD3\n";
+ $offsets = [];
+ foreach ($objects as $id => $body) {
+ $offsets[$id] = strlen($pdf);
+ $pdf .= sprintf("%d 0 obj\n%s\nendobj\n", $id, $body);
+ }
+
+ $xrefPos = strlen($pdf);
+ $maxObj = max(array_keys($objects));
+ $pdf .= sprintf("xref\n0 %d\n", $maxObj + 1);
+ $pdf .= "0000000000 65535 f \n";
+ for ($id = 1; $id <= $maxObj; $id++) {
+ $pdf .= isset($offsets[$id])
+ ? sprintf("%010d 00000 n \n", $offsets[$id])
+ : "0000000000 65535 f \n";
+ }
+ $pdf .= sprintf(
+ "trailer\n<< /Size %d /Root 1 0 R /Info << /Producer (Westreiche Charakterbogen) >> >>\nstartxref\n%d\n%%%%EOF\n",
+ $maxObj + 1,
+ $xrefPos
+ );
+
+ return $pdf;
+ }
+}
diff --git a/westreiche_website/app/portrait.php b/westreiche_website/app/portrait.php
new file mode 100644
index 0000000..406a0a1
--- /dev/null
+++ b/westreiche_website/app/portrait.php
@@ -0,0 +1,177 @@
+ false, 'error' => 'Bitte eine Bilddatei auswählen.'];
+ }
+ if ($error === UPLOAD_ERR_INI_SIZE || $error === UPLOAD_ERR_FORM_SIZE) {
+ return ['ok' => false, 'error' => 'Das Bild ist zu groß (höchstens 5 MB).'];
+ }
+ if ($error !== UPLOAD_ERR_OK) {
+ return ['ok' => false, 'error' => 'Der Upload ist fehlgeschlagen (Code ' . $error . ').'];
+ }
+
+ $tmp = (string) ($file['tmp_name'] ?? '');
+ if ($tmp === '' || !is_uploaded_file($tmp)) {
+ return ['ok' => false, 'error' => 'Der Upload konnte nicht geprüft werden.'];
+ }
+ if ((int) ($file['size'] ?? 0) > WS_PORTRAIT_MAX_BYTES) {
+ return ['ok' => false, 'error' => 'Das Bild ist zu groß (höchstens 5 MB).'];
+ }
+ if (!function_exists('imagecreatefromstring')) {
+ return ['ok' => false, 'error' => 'Auf dem Server fehlt die GD-Erweiterung.'];
+ }
+
+ $info = @getimagesize($tmp);
+ if ($info === false || !in_array($info[2], [IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP], true)) {
+ return ['ok' => false, 'error' => 'Nur JPEG, PNG oder WebP werden angenommen.'];
+ }
+
+ $image = @imagecreatefromstring((string) file_get_contents($tmp));
+ if ($image === false) {
+ return ['ok' => false, 'error' => 'Das Bild konnte nicht gelesen werden.'];
+ }
+
+ $width = imagesx($image);
+ $height = imagesy($image);
+ $scale = min(1.0, WS_PORTRAIT_MAX_EDGE / max($width, $height));
+ $newWidth = max(1, (int) round($width * $scale));
+ $newHeight = max(1, (int) round($height * $scale));
+
+ $canvas = imagecreatetruecolor($newWidth, $newHeight);
+ // JPEG kennt keine Transparenz – weißer Grund statt schwarzer Flächen.
+ $white = imagecolorallocate($canvas, 250, 245, 230);
+ imagefilledrectangle($canvas, 0, 0, $newWidth, $newHeight, $white);
+ imagecopyresampled($canvas, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
+ imagedestroy($image);
+
+ $dir = portrait_dir();
+ if (!is_dir($dir) && !@mkdir($dir, 0755, true) && !is_dir($dir)) {
+ imagedestroy($canvas);
+ return ['ok' => false, 'error' => 'Der Bildordner konnte nicht angelegt werden.'];
+ }
+
+ $fileName = sprintf('c%d-%s.jpg', $characterId, bin2hex(random_bytes(6)));
+ $absolute = $dir . '/' . $fileName;
+ $saved = imagejpeg($canvas, $absolute, 86);
+ imagedestroy($canvas);
+
+ if (!$saved) {
+ return ['ok' => false, 'error' => 'Das Bild konnte nicht gespeichert werden.'];
+ }
+
+ portrait_delete_file((string) current_portrait((int) $characterId));
+ db()->prepare('UPDATE characters SET portrait = ?, updated_at = ? WHERE id = ?')
+ ->execute([WS_PORTRAIT_REL_DIR . '/' . $fileName, utc_now(), $characterId]);
+
+ return ['ok' => true, 'error' => ''];
+}
+
+function current_portrait(int $characterId): string
+{
+ $stmt = db()->prepare('SELECT portrait FROM characters WHERE id = ? LIMIT 1');
+ $stmt->execute([$characterId]);
+ return (string) ($stmt->fetchColumn() ?: '');
+}
+
+function portrait_remove(int $characterId): void
+{
+ portrait_delete_file(current_portrait($characterId));
+ db()->prepare('UPDATE characters SET portrait = \'\', updated_at = ? WHERE id = ?')
+ ->execute([utc_now(), $characterId]);
+}
+
+function portrait_delete_file(string $relPath): void
+{
+ $relPath = ltrim($relPath, '/');
+ if ($relPath === '' || !str_starts_with($relPath, WS_PORTRAIT_REL_DIR . '/')) {
+ return;
+ }
+ $absolute = WS_ROOT . '/' . $relPath;
+ if (is_file($absolute)) {
+ @unlink($absolute);
+ }
+}
+
+/**
+ * JPEG-Bytes für den PDF-Export: eigenes Bild direkt, Platzhalter (WebP)
+ * wird über GD in JPEG umgewandelt.
+ */
+function portrait_jpeg_bytes(array $character): string
+{
+ $stored = (string) ($character['portrait'] ?? '');
+ if ($stored !== '' && is_file(WS_ROOT . '/' . ltrim($stored, '/'))) {
+ $bytes = (string) file_get_contents(WS_ROOT . '/' . ltrim($stored, '/'));
+ if (strncmp($bytes, "\xFF\xD8", 2) === 0) {
+ return $bytes;
+ }
+ }
+
+ $placeholder = portrait_placeholder_rel((string) ($character['class_name'] ?? ''));
+ if ($placeholder === '' || !function_exists('imagecreatefromwebp')) {
+ return '';
+ }
+ $image = @imagecreatefromwebp(WS_ROOT . '/' . $placeholder);
+ if ($image === false) {
+ return '';
+ }
+ ob_start();
+ imagejpeg($image, null, 88);
+ $bytes = (string) ob_get_clean();
+ imagedestroy($image);
+ return $bytes;
+}
diff --git a/westreiche_website/app/rules.php b/westreiche_website/app/rules.php
new file mode 100644
index 0000000..0782185
--- /dev/null
+++ b/westreiche_website/app/rules.php
@@ -0,0 +1,249 @@
+ ['STR', 'Stärke'],
+ 'attr_dex' => ['DEX', 'Geschicklichkeit'],
+ 'attr_con' => ['CON', 'Konstitution'],
+ 'attr_int' => ['INT', 'Intelligenz'],
+ 'attr_wis' => ['WIS', 'Weisheit'],
+ 'attr_cha' => ['CHA', 'Charisma'],
+];
+
+const WS_CLASSES = [
+ 'Kämpfer', 'Ritter', 'Paladin', 'Barbar', 'Waldläufer',
+ 'Dieb', 'Assassine', 'Barde',
+ 'Magier', 'Illusionist', 'Kleriker', 'Druide',
+];
+
+const WS_SAVES = [
+ 'save_death' => 'Tod & Gift',
+ 'save_wand' => 'Zauberstäbe',
+ 'save_paralysis' => 'Lähmung',
+ 'save_breath' => 'Atemwaffen',
+ 'save_spell' => 'Zauber',
+];
+
+const WS_ALIGNMENTS = ['Rechtschaffen', 'Neutral', 'Chaotisch', 'Gut', 'Böse', '–'];
+
+const WS_ITEM_CATEGORIES = ['Waffe', 'Rüstung', 'Schild', 'Ausrüstung', 'Verbrauch', 'Schatz', 'Sonstiges'];
+
+/**
+ * Fertigkeitengruppen wie auf dem Westreiche-Charakterbogen
+ * (RPG/6-Dokumente/Charakterbogen.pdf): KÖRPER, WILDNIS, SOZIAL, WISSEN.
+ */
+const WS_SKILL_GROUPS = ['Körper', 'Wildnis', 'Sozial', 'Wissen'];
+const WS_SKILL_CATEGORIES = WS_SKILL_GROUPS;
+
+/**
+ * Offizieller Fertigkeitenkatalog des Charakterbogens:
+ * Name => [Attribut, Gruppe]. Startwert ist der Attributsbonus.
+ */
+const WS_SKILL_CATALOG = [
+ 'Ausdauer' => ['CON', 'Körper'],
+ 'Balancieren' => ['DEX', 'Körper'],
+ 'Fliegen' => ['DEX', 'Körper'],
+ 'Klettern' => ['STR', 'Körper'],
+ 'Reiten & Wagenführung' => ['DEX', 'Körper'],
+ 'Schleichen' => ['DEX', 'Körper'],
+ 'Schwimmen' => ['CON', 'Körper'],
+ 'Wahrnehmung' => ['WIS', 'Körper'],
+
+ 'Wildniskunde' => ['WIS', 'Wildnis'],
+ 'Nahrung finden' => ['WIS', 'Wildnis'],
+ 'Navigation' => ['WIS', 'Wildnis'],
+ 'Orientierung' => ['INT', 'Wildnis'],
+ 'Pflanzenkunde' => ['INT', 'Wildnis'],
+ 'Segeln + Schiffahrt' => ['INT', 'Wildnis'],
+ 'Seilkunde' => ['DEX', 'Wildnis'],
+ 'Spurenlesen' => ['WIS', 'Wildnis'],
+
+ 'Anführen' => ['CHA', 'Sozial'],
+ 'Aufführung' => ['CHA', 'Sozial'],
+ 'Einschüchtern' => ['STR', 'Sozial'],
+ 'Etikette' => ['CHA', 'Sozial'],
+ 'Handeln & Schätzen' => ['WIS', 'Sozial'],
+ 'Überzeugen' => ['CHA', 'Sozial'],
+ 'Verstellen' => ['INT', 'Sozial'],
+
+ 'Alchimie' => ['INT', 'Wissen'],
+ 'Geschichts + Sagenkunde' => ['INT', 'Wissen'],
+ 'Handwerk' => ['DEX', 'Wissen'],
+ 'Heilkunde: Geist' => ['WIS', 'Wissen'],
+ 'Heilkunde: Gift' => ['INT', 'Wissen'],
+ 'Heilkunde: Krankheiten' => ['INT', 'Wissen'],
+ 'Heilkunde: Wunden' => ['WIS', 'Wissen'],
+ 'Religionskunde' => ['INT', 'Wissen'],
+ 'Verwaltung' => ['INT', 'Wissen'],
+ 'Zauberkunde' => ['INT', 'Wissen'],
+];
+
+const WS_CHARACTER_STATUS = [
+ 'active' => 'im Spiel',
+ 'dead' => 'gefallen',
+ 'retired' => 'im Ruhestand',
+];
+
+/**
+ * Attributsbonus nach Hausregel V1.1:
+ * 3 → −3, 4–5 → −2, 6–8 → −1, 9–12 → 0, 13–15 → +1, 16–17 → +2, 18 → +3.
+ * Werte über 18 werden wie 18 behandelt.
+ */
+function attribute_bonus(int $value): int
+{
+ return match (true) {
+ $value <= 3 => -3,
+ $value <= 5 => -2,
+ $value <= 8 => -1,
+ $value <= 12 => 0,
+ $value <= 15 => 1,
+ $value <= 17 => 2,
+ default => 3,
+ };
+}
+
+function signed(int $value): string
+{
+ return $value > 0 ? '+' . $value : (string) $value;
+}
+
+/**
+ * CSS-Klasse für einen Bonus: positive Werte grün, Null grau, negative rot.
+ */
+function bonus_class(int $value): string
+{
+ return $value > 0 ? 'bonus-pos' : ($value < 0 ? 'bonus-neg' : 'bonus-zero');
+}
+
+/** Rettungswurf-Feld formatieren; leere Werte bleiben ein Gedankenstrich. */
+function save_display(mixed $value): string
+{
+ if ($value === null || $value === '') {
+ return '–';
+ }
+ return (string) (int) $value;
+}
+
+/* ------------------------------------------------------- Rettungswürfe */
+
+/**
+ * Rettungswurf-Grundwerte je Klasse und Stufe (Würfelwurf ≥ Wert, OSE-SRD).
+ *
+ * Aufbau: Klassenname → Liste aus [bis Stufe, [Tod & Gift, Zauberstäbe,
+ * Lähmung, Atemwaffen, Zauber]]. Der erste Eintrag, dessen Stufengrenze
+ * erreicht ist, gilt. Die Westreiche-Klassen ohne eigene Tabelle laufen auf
+ * der passenden Grundklasse: Kämpfer, Ritter, Paladin, Barbar und Waldläufer
+ * auf der Kämpfer-Tabelle, Druide auf der Kleriker-, Assassine und Barde auf
+ * der Diebes-Tabelle.
+ */
+const WS_SAVE_TABLES = [
+ 'Kämpfer' => [
+ [3, [12, 13, 14, 15, 16]],
+ [6, [10, 11, 12, 13, 14]],
+ [9, [8, 9, 10, 11, 12]],
+ [12, [6, 7, 8, 9, 10]],
+ [99, [4, 5, 6, 7, 8]],
+ ],
+ 'Kleriker' => [
+ [3, [11, 12, 14, 16, 15]],
+ [6, [9, 10, 12, 14, 13]],
+ [9, [6, 7, 9, 11, 10]],
+ [12, [3, 5, 7, 8, 8]],
+ [99, [2, 3, 5, 6, 6]],
+ ],
+ 'Magier' => [
+ [5, [13, 14, 13, 16, 15]],
+ [10, [11, 12, 11, 14, 12]],
+ [99, [8, 9, 8, 11, 8]],
+ ],
+ 'Dieb' => [
+ [4, [13, 14, 13, 16, 15]],
+ [8, [12, 13, 11, 14, 13]],
+ [12, [11, 10, 9, 12, 10]],
+ [99, [9, 8, 7, 10, 8]],
+ ],
+];
+
+/** Klasse → Grundklasse für Rettungswürfe. */
+const WS_SAVE_BASE_CLASS = [
+ 'Ritter' => 'Kämpfer',
+ 'Paladin' => 'Kämpfer',
+ 'Barbar' => 'Kämpfer',
+ 'Waldläufer' => 'Kämpfer',
+ 'Druide' => 'Kleriker',
+ 'Illusionist' => 'Magier',
+ 'Assassine' => 'Dieb',
+ 'Barde' => 'Dieb',
+];
+
+/** Rettungswürfe für Klasse + Stufe als Feld → Wert. */
+function saving_throws_for(string $className, int $level): array
+{
+ $base = WS_SAVE_BASE_CLASS[$className] ?? $className;
+ $table = WS_SAVE_TABLES[$base] ?? WS_SAVE_TABLES['Kämpfer'];
+ $level = max(1, $level);
+ $values = $table[count($table) - 1][1];
+ foreach ($table as [$maxLevel, $row]) {
+ if ($level <= $maxLevel) {
+ $values = $row;
+ break;
+ }
+ }
+ $fields = array_keys(WS_SAVES);
+ $result = [];
+ foreach ($fields as $index => $field) {
+ $result[$field] = $values[$index];
+ }
+ return $result;
+}
+
+/* ----------------------------------------- Waffen und Rüstungen (Ableitung) */
+
+/** Trefferwurf mit einer Waffe: Grundangriff + Attributsbonus + Waffenbonus. */
+function weapon_attack_total(array $character, array $weapon): int
+{
+ $attribute = ($weapon['category'] ?? 'Nahkampf') === 'Fernkampf' ? 'attr_dex' : 'attr_str';
+ return (int) ($character['attack_bonus'] ?? 0)
+ + attribute_bonus((int) ($character[$attribute] ?? 10))
+ + (int) ($weapon['attack_bonus'] ?? 0);
+}
+
+/** Schaden mit Waffe: Würfelausdruck + Attributsbonus (bei Fernkampf Geschick). */
+function weapon_damage_total(array $character, array $weapon): string
+{
+ $damage = trim((string) ($weapon['damage'] ?? ''));
+ if ($damage === '') {
+ return '–';
+ }
+ $attribute = ($weapon['category'] ?? 'Nahkampf') === 'Fernkampf' ? 'attr_dex' : 'attr_str';
+ $bonus = attribute_bonus((int) ($character[$attribute] ?? 10));
+ return $bonus === 0 ? $damage : $damage . signed($bonus);
+}
+
+/**
+ * Rüstungsklasse: 10 + Geschicklichkeitsbonus + alle angelegten Rüstungsteile.
+ * Ein manueller Wert in characters.ac (nicht NULL) überschreibt das.
+ */
+function armor_class_total(array $character, array $armors): array
+{
+ $dexterity = attribute_bonus((int) ($character['attr_dex'] ?? 10));
+ $armorBonus = 0;
+ foreach ($armors as $armor) {
+ if ((int) ($armor['equipped'] ?? 0) === 1) {
+ $armorBonus += (int) ($armor['ac_bonus'] ?? 0);
+ }
+ }
+ $derived = 10 + $dexterity + $armorBonus;
+ $manual = $character['ac'] ?? null;
+ $isManual = $manual !== null && $manual !== '' && (int) $manual > 0;
+ return [
+ 'derived' => $derived,
+ 'manual' => $isManual ? (int) $manual : null,
+ 'total' => $isManual ? (int) $manual : $derived,
+ 'dexterity' => $dexterity,
+ 'armor' => $armorBonus,
+ 'manual_active' => $isManual,
+ ];
+}
diff --git a/westreiche_website/app/sheet.php b/westreiche_website/app/sheet.php
new file mode 100644
index 0000000..1014e8d
--- /dev/null
+++ b/westreiche_website/app/sheet.php
@@ -0,0 +1,373 @@
+ [...], 'spells' => ['arkan'=>[], 'klerikal'=>[]], 'items' => [...]]
+ */
+function character_pdf(array $c, array $extra): string
+{
+ $ink = pdf_color('#1a1712');
+ $soft = pdf_color('#4a4336');
+ $gold = pdf_color('#a8862a');
+ $goldLight = pdf_color('#d9be6a');
+ $parchment = pdf_color('#faf5e6');
+ $parchment2 = pdf_color('#f2e9d2');
+
+ $pdf = new WsPdf();
+ $W = WsPdf::width();
+ $H = WsPdf::height();
+ $M = 34.0;
+ $inner = $W - 2 * $M;
+
+ $pageNo = 0;
+ $y = 0.0;
+
+ $frame = static function (WsPdf $pdf, int $pageNo) use ($W, $H, $M, $gold, $goldLight, $parchment, $parchment2, $ink, $soft): void {
+ $pdf->rect(0, 0, $W, $H, $parchment);
+ $pdf->rect(0, 0, $W, 16, $parchment2);
+ $pdf->rect(0, $H - 16, $W, 16, $parchment2);
+ $pdf->rect($M - 12, 18, $W - 2 * ($M - 12), $H - 36, null, $gold, 1.2);
+ $pdf->rect($M - 8, 22, $W - 2 * ($M - 8), $H - 44, null, $goldLight, 0.4);
+
+ // Ecken-Ornamente
+ foreach ([[$M - 12, 18], [$W - $M + 12 - 14, 18], [$M - 12, $H - 32], [$W - $M + 12 - 14, $H - 32]] as [$cx, $cy]) {
+ $pdf->rect($cx, $cy, 14, 14, $gold);
+ }
+
+ $pdf->textCenter($W / 2, $H - 22, 7.5, 'F1', $soft, 'Westreiche · Chronik der Zauberturm-Runde · zauberturm.de');
+ $pdf->textRight($W - $M, $H - 40, 7.5, 'F1', $soft, 'Seite ' . $pageNo);
+ };
+
+ $newPage = static function () use (&$pageNo, &$y, $pdf, $frame): void {
+ if ($pageNo > 0) {
+ $pdf->addPage();
+ }
+ $pageNo++;
+ $frame($pdf, $pageNo);
+ $y = 52.0;
+ };
+
+ $newPage();
+
+ $ensure = static function (float $needed) use (&$y, $newPage, $H): void {
+ if ($y + $needed > $H - 70) {
+ $newPage();
+ }
+ };
+
+ $sectionTitle = static function (string $label) use (&$y, $pdf, $gold, $ink, $ensure, $M, $inner): void {
+ $ensure(34);
+ $y += 12;
+ $pdf->rect($M, $y, 3.2, 10, $gold);
+ $pdf->text($M + 8, $y + 9, 11.5, 'F4', $ink, mb_strtoupper($label, 'UTF-8'));
+ $pdf->line($M, $y + 14, $M + $inner, $y + 14, $gold, 0.4);
+ $y += 22;
+ };
+
+ $paragraph = static function (string $text, float $size = 8.6) use (&$y, $pdf, $ink, $ensure, $M, $inner): void {
+ if (trim($text) === '') {
+ return;
+ }
+ foreach (preg_split('/\R{2,}/', trim($text)) ?: [] as $block) {
+ foreach (WsPdf::wrap(str_replace("\n", ' ', $block), $size, 'F3', $inner) as $line) {
+ $ensure(12);
+ $pdf->text($M, $y + 9, $size, 'F3', $ink, $line);
+ $y += 11.4;
+ }
+ $y += 3;
+ }
+ };
+
+ /* ---------------------------------------------------------------- Kopf */
+ $portraitW = 74.0;
+ $portraitH = 94.0;
+ $pX = $W - $M - $portraitW;
+ $textRight = $pX - 12;
+
+ $pdf->text($M, $y, 7.5, 'F2', $gold, 'CHARAKTERBOGEN');
+ $nameSize = 24.0;
+ $nameText = (string) $c['name'];
+ while ($nameText !== '' && WsPdf::textWidth($nameText, $nameSize, 'F4') > $textRight - $M) {
+ $nameText = mb_substr($nameText, 0, -1, 'UTF-8');
+ }
+ if ($nameText !== (string) $c['name']) {
+ $nameText = rtrim($nameText) . '…';
+ }
+ $pdf->text($M, $y + 30, $nameSize, 'F4', $ink, $nameText);
+ $titleLine = [];
+ if ((string) $c['title'] !== '') {
+ $titleLine[] = (string) $c['title'];
+ }
+ $titleLine[] = (string) $c['class_name'];
+ $titleLine[] = 'Stufe ' . (int) $c['level'];
+ if ((string) $c['alignment'] !== '' && (string) $c['alignment'] !== '–') {
+ $titleLine[] = 'Gesinnung: ' . (string) $c['alignment'];
+ }
+ $titleLine[] = character_status_label((string) $c['status']);
+ $titleText = implode(' · ', $titleLine);
+ while ($titleText !== '' && WsPdf::textWidth($titleText, 9.6, 'F5') > $textRight - $M) {
+ $titleText = mb_substr($titleText, 0, -1, 'UTF-8');
+ }
+ $pdf->text($M, $y + 46, 9.6, 'F5', $soft, $titleText);
+
+ // Porträt rechts (sonst Monogramm)
+ $pH = $y + 2;
+ $portraitBytes = portrait_jpeg_bytes($c);
+ if ($portraitBytes === '' || !$pdf->imageJpeg($portraitBytes, $pX, $pH, $portraitW, $portraitH, true)) {
+ $cgX = $W - $M - 26;
+ $cgY = $y + 26;
+ $pdf->rect($cgX - 26, $cgY - 26, 52, 52, null, $gold, 1.0);
+ $pdf->rect($cgX - 22, $cgY - 22, 44, 44, null, $goldLight, 0.4);
+ $pdf->textCenter($cgX, $cgY + 8, 20, 'F4', $gold, mb_strtoupper(mb_substr((string) $c['name'], 0, 1), 'UTF-8'));
+ }
+ $pdf->rect($pX - 2.5, $pH - 2.5, $portraitW + 5, $portraitH + 5, null, $gold, 1.0);
+
+ $y += 78;
+
+ /* ---------------------------------------------------------- Attribute */
+ $sectionTitle('Attribute');
+ $boxW = 60.0;
+ $boxH = 54.0;
+ $gap = 6.0;
+ $x = $M;
+ foreach (WS_ATTRIBUTES as $field => [$short, $label]) {
+ $value = (int) ($c[$field] ?? 10);
+ $pdf->rect($x, $y, $boxW, $boxH, $parchment2, $gold, 0.5);
+ $pdf->textCenter($x + $boxW / 2, $y + 13, 7.2, 'F2', $soft, $short);
+ $pdf->textCenter($x + $boxW / 2, $y + 34, 17, 'F4', $ink, (string) $value);
+ $pdf->textCenter($x + $boxW / 2, $y + 46, 8, 'F2', $gold, signed(attribute_bonus($value)));
+ $x += $boxW + $gap;
+ }
+
+ // Kampfblock rechts
+ $combatX = $x + 4;
+ $combatW = $W - $M - $combatX;
+ $pdf->rect($combatX, $y, $combatW, $boxH, null, $gold, 0.6);
+ $combatRows = [
+ ['Trefferpunkte', (int) $c['hp_current'] . ' / ' . (int) $c['hp_max']],
+ ['Rüstungsklasse', (string) (int) ($extra['ac']['total'] ?? 10)],
+ ['Angriff', signed((int) $c['attack_bonus'])],
+ ['Gold', (int) $c['gold_coins'] . ' GM'],
+ ];
+ $ry = $y + 12;
+ $rowStep = 12.0;
+ foreach ($combatRows as $i => [$label, $value]) {
+ $pdf->text($combatX + 7, $ry, 7.0, 'F1', $soft, $label);
+ $pdf->textRight($combatX + $combatW - 7, $ry, 9, 'F2', $ink, $value);
+ $ry += $rowStep;
+ }
+ $y += $boxH + 6;
+
+ /* ----------------------------------------------------- Rettungswürfe */
+ $saves = [];
+ foreach (WS_SAVES as $field => $label) {
+ $saves[$label] = save_display($c[$field] ?? null);
+ }
+ $sectionTitle('Rettungswürfe');
+ $sw = ($inner - 4 * 5) / 5;
+ $sx = $M;
+ foreach ($saves as $label => $value) {
+ $pdf->rect($sx, $y, $sw, 32, $parchment2, $gold, 0.4);
+ $pdf->textCenter($sx + $sw / 2, $y + 12, 6.8, 'F1', $soft, $label);
+ $pdf->textCenter($sx + $sw / 2, $y + 27, 13, 'F4', $ink, $value);
+ $sx += $sw + 5;
+ }
+ $y += 38;
+
+ /* ------------------------------------------------- Bewaffnung / Rüstung */
+ $weapons = $extra['weapons'] ?? [];
+ if ($weapons !== []) {
+ $sectionTitle('Bewaffnung');
+ $ensure(14);
+ $pdf->text($M, $y + 8, 6.8, 'F2', $soft, 'WAFFE');
+ $pdf->text($M + 200, $y + 8, 6.8, 'F2', $soft, 'ART');
+ $pdf->textRight($M + $inner - 74, $y + 8, 6.8, 'F2', $soft, 'TREFFER');
+ $pdf->textRight($M + $inner, $y + 8, 6.8, 'F2', $soft, 'SCHADEN');
+ $y += 12;
+ $pdf->line($M, $y, $M + $inner, $y, $gold, 0.4);
+ $y += 4;
+ foreach ($weapons as $weapon) {
+ $ensure(13);
+ $pdf->text($M, $y + 8.5, 8.6, 'F3', $ink, shorten((string) $weapon['name'], 40));
+ $pdf->text($M + 200, $y + 8.5, 7.6, 'F1', $soft, (string) $weapon['category']);
+ $pdf->textRight($M + $inner - 74, $y + 8.5, 8.6, 'F2', $ink, signed(weapon_attack_total($c, $weapon)));
+ $pdf->textRight($M + $inner, $y + 8.5, 8.6, 'F3', $ink, weapon_damage_total($c, $weapon));
+ $pdf->line($M, $y + 10.8, $M + $inner, $y + 10.8, $goldLight, 0.22);
+ $y += 13;
+ }
+ $y += 4;
+ }
+
+ $armors = $extra['armors'] ?? [];
+ if ($armors !== []) {
+ $sectionTitle('Rüstung');
+ $ensure(14);
+ $pdf->text($M, $y + 8, 6.8, 'F2', $soft, 'TEIL');
+ $pdf->text($M + 200, $y + 8, 6.8, 'F2', $soft, 'ART');
+ $pdf->textRight($M + $inner - 60, $y + 8, 6.8, 'F2', $soft, 'RK-BONUS');
+ $pdf->textRight($M + $inner, $y + 8, 6.8, 'F2', $soft, 'STATUS');
+ $y += 12;
+ $pdf->line($M, $y, $M + $inner, $y, $gold, 0.4);
+ $y += 4;
+ foreach ($armors as $armor) {
+ $ensure(13);
+ $pdf->text($M, $y + 8.5, 8.6, 'F3', $ink, shorten((string) $armor['name'], 40));
+ $pdf->text($M + 200, $y + 8.5, 7.6, 'F1', $soft, (string) $armor['kind']);
+ $pdf->textRight($M + $inner - 60, $y + 8.5, 8.6, 'F2', $ink, signed((int) $armor['ac_bonus']));
+ $pdf->textRight($M + $inner, $y + 8.5, 7.6, 'F1', $soft, (int) $armor['equipped'] === 1 ? 'angelegt' : 'abgelegt');
+ $pdf->line($M, $y + 10.8, $M + $inner, $y + 10.8, $goldLight, 0.22);
+ $y += 13;
+ }
+ $acInfo = $extra['ac'] ?? null;
+ if (is_array($acInfo)) {
+ $ensure(14);
+ $pdf->text($M, $y + 9, 8.2, 'F5', $soft, sprintf(
+ 'Rüstungsklasse gesamt: 10 %s Geschick %s Rüstung = %d%s',
+ signed((int) $acInfo['dexterity']),
+ signed((int) $acInfo['armor']),
+ (int) $acInfo['total'],
+ $acInfo['manual_active'] ? ' (manuell überschrieben)' : ''
+ ));
+ $y += 14;
+ }
+ $y += 2;
+ }
+
+ /* -------------------------------------------------------- Fertigkeiten */
+ $skills = $extra['skills'] ?? [];
+ if ($skills !== []) {
+ $sectionTitle('Fertigkeiten');
+ foreach (skills_grouped($skills) as $group => $rows) {
+ $ensure(26);
+ $pdf->text($M, $y + 9, 7.0, 'F2', $gold, mb_strtoupper($group, 'UTF-8'));
+ $pdf->line($M, $y + 12.5, $M + $inner, $y + 12.5, $goldLight, 0.3);
+ $y += 15;
+ $colW = ($inner - 16) / 2;
+ $perColumn = (int) ceil(count($rows) / 2);
+ for ($i = 0; $i < $perColumn; $i++) {
+ $ensure(13);
+ foreach ([0, 1] as $col) {
+ $index = $i + $col * $perColumn;
+ if (!isset($rows[$index])) {
+ continue;
+ }
+ $skill = $rows[$index];
+ $cx = $M + $col * ($colW + 16);
+ $mod = skill_attribute_modifier($c, $skill);
+ $pdf->text($cx, $y + 8.5, 8.4, 'F3', $ink, shorten((string) $skill['name'], 34));
+ $pdf->text($cx + $colW - 64, $y + 8.2, 6.6, 'F1', $soft, trim((string) ($skill['attribute'] ?? '')));
+ $pdf->textRight($cx + $colW - 28, $y + 8.2, 6.8, 'F1', $soft, $mod === null ? '–' : signed($mod));
+ $pdf->textRight($cx + $colW, $y + 8.5, 8.4, 'F2', $gold, signed((int) $skill['bonus']));
+ $pdf->line($cx, $y + 10.4, $cx + $colW, $y + 10.4, $goldLight, 0.22);
+ }
+ $y += 12.6;
+ }
+ $y += 4;
+ }
+ }
+
+ /* ------------------------------------------------- Zauber & Liturgien */
+ $spells = $extra['spells'] ?? ['arkan' => [], 'klerikal' => []];
+ $spellBlocks = [
+ 'arkan' => ['Arkane Zauber', $spells['arkan'] ?? []],
+ 'klerikal' => ['Göttliche Liturgien', $spells['klerikal'] ?? []],
+ ];
+ foreach ($spellBlocks as $key => [$label, $list]) {
+ if ($list === []) {
+ continue;
+ }
+ $sectionTitle($label);
+ $byGrade = [];
+ foreach ($list as $spell) {
+ $byGrade[(int) $spell['grade']][] = $spell;
+ }
+ ksort($byGrade);
+ foreach ($byGrade as $grade => $entries) {
+ $names = [];
+ foreach ($entries as $entry) {
+ $names[] = (string) $entry['name'];
+ }
+ foreach (WsPdf::wrap('Grad ' . $grade . ': ' . implode(', ', $names), 8.6, 'F3', $inner - 6) as $i => $line) {
+ $ensure(12);
+ if ($i === 0) {
+ $pdf->text($M, $y + 8.5, 8.6, 'F2', $gold, '');
+ }
+ $pdf->text($M + 2, $y + 8.5, 8.6, 'F3', $ink, $line);
+ $y += 11.6;
+ }
+ $y += 2;
+ }
+ $y += 2;
+ }
+
+ /* -------------------------------------------------------------- Inventar */
+ $items = $extra['items'] ?? [];
+ if ($items !== []) {
+ $sectionTitle('Inventar');
+ $pdf->text($M, $y + 8, 6.8, 'F2', $soft, 'ANZAHL');
+ $pdf->text($M + 52, $y + 8, 6.8, 'F2', $soft, 'GEGENSTAND');
+ $pdf->text($M + $inner - 78, $y + 8, 6.8, 'F2', $soft, 'ART');
+ $pdf->textRight($M + $inner, $y + 8, 6.8, 'F2', $soft, 'WERT');
+ $y += 12;
+ $pdf->line($M, $y, $M + $inner, $y, $gold, 0.4);
+ $y += 4;
+ foreach ($items as $item) {
+ $ensure(12);
+ $pdf->text($M, $y + 8, 8.4, 'F1', $ink, ((int) $item['qty']) . '×');
+ $pdf->text($M + 52, $y + 8, 8.6, 'F3', $ink, shorten((string) $item['name'], 56));
+ $pdf->text($M + $inner - 78, $y + 8, 7.4, 'F1', $soft, (string) $item['category']);
+ $pdf->textRight($M + $inner, $y + 8, 8.2, 'F3', $ink, (string) ($item['value'] !== '' ? $item['value'] : '–'));
+ $pdf->line($M, $y + 10.4, $M + $inner, $y + 10.4, $goldLight, 0.22);
+ $y += 12.6;
+ }
+ $y += 4;
+ }
+
+ /* ------------------------------------------------------ Person & Notizen */
+ $facts = [];
+ if ((string) $c['deity'] !== '') {
+ $facts[] = 'Gottheit: ' . $c['deity'];
+ }
+ if ((string) $c['age'] !== '') {
+ $facts[] = 'Alter: ' . $c['age'];
+ }
+ if ((string) $c['height'] !== '') {
+ $facts[] = 'Größe: ' . $c['height'];
+ }
+ if ((string) $c['weight'] !== '') {
+ $facts[] = 'Gewicht: ' . $c['weight'];
+ }
+ if ($facts !== []) {
+ $sectionTitle('Person');
+ $paragraph(implode(' · ', $facts), 9);
+ }
+
+ foreach (['appearance' => 'Erscheinung', 'background' => 'Hintergrund', 'notes' => 'Notizen'] as $field => $label) {
+ if (trim((string) $c[$field]) === '') {
+ continue;
+ }
+ $sectionTitle($label);
+ $paragraph((string) $c[$field]);
+ }
+
+ return $pdf->output();
+}
diff --git a/westreiche_website/app/util.php b/westreiche_website/app/util.php
new file mode 100644
index 0000000..45a376c
--- /dev/null
+++ b/westreiche_website/app/util.php
@@ -0,0 +1,217 @@
+format('d.m.Y H:i');
+}
+
+function e(mixed $value): string
+{
+ return htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
+}
+
+function url(string $path = '/'): string
+{
+ $base = rtrim((string) config('app.base_path', ''), '/');
+ if ($path === '' || $path[0] !== '/') {
+ $path = '/' . $path;
+ }
+ return $base . $path;
+}
+
+/** Cache-Buster: bei Änderungen an app.css/app.js erhöhen. */
+const WS_ASSET_VERSION = '5';
+
+function asset(string $path): string
+{
+ return url('/assets/' . ltrim($path, '/')) . '?v=' . WS_ASSET_VERSION;
+}
+
+function redirect(string $path, int $status = 303): never
+{
+ header('Location: ' . url($path), true, $status);
+ exit;
+}
+
+function current_path(): string
+{
+ $path = (string) parse_url((string) ($_SERVER['REQUEST_URI'] ?? '/'), PHP_URL_PATH);
+ $base = rtrim((string) config('app.base_path', ''), '/');
+ if ($base !== '' && str_starts_with($path, $base)) {
+ $path = substr($path, strlen($base));
+ }
+ return '/' . trim($path, '/');
+}
+
+function client_ip(): string
+{
+ $ip = (string) ($_SERVER['REMOTE_ADDR'] ?? '');
+ return $ip !== '' ? substr($ip, 0, 45) : '0.0.0.0';
+}
+
+function request_method(): string
+{
+ return strtoupper((string) ($_SERVER['REQUEST_METHOD'] ?? 'GET'));
+}
+
+function is_post(): bool
+{
+ return request_method() === 'POST';
+}
+
+function post_string(string $key, string $default = ''): string
+{
+ $value = $_POST[$key] ?? $default;
+ return is_string($value) ? trim($value) : $default;
+}
+
+function post_int(string $key, int $default = 0): int
+{
+ $value = $_POST[$key] ?? null;
+ if (is_int($value)) {
+ return $value;
+ }
+ return is_string($value) && preg_match('/^-?\d+$/', trim($value)) === 1 ? (int) $value : $default;
+}
+
+function query_string(string $key, string $default = ''): string
+{
+ $value = $_GET[$key] ?? $default;
+ return is_string($value) ? trim($value) : $default;
+}
+
+function query_int(string $key, int $default = 0): int
+{
+ $value = $_GET[$key] ?? null;
+ return is_numeric($value) ? (int) $value : $default;
+}
+
+function flash(string $type, string $message): void
+{
+ $_SESSION['flash'][] = ['type' => $type, 'message' => $message];
+}
+
+function flash_pull(): array
+{
+ $items = $_SESSION['flash'] ?? [];
+ unset($_SESSION['flash']);
+ return is_array($items) ? $items : [];
+}
+
+function csrf_token(): string
+{
+ if (empty($_SESSION['csrf'])) {
+ $_SESSION['csrf'] = bin2hex(random_bytes(32));
+ }
+ return (string) $_SESSION['csrf'];
+}
+
+function csrf_field(): string
+{
+ return ' ';
+}
+
+function csrf_valid(): bool
+{
+ $sent = $_POST['_csrf'] ?? '';
+ return is_string($sent) && $sent !== '' && hash_equals(csrf_token(), $sent);
+}
+
+function require_post(): void
+{
+ if (!is_post()) {
+ abort_page(405, 'Diese Aktion erfordert ein Formular.');
+ }
+ if (!csrf_valid()) {
+ abort_page(419, 'Die Sitzung ist abgelaufen. Bitte erneut versuchen.');
+ }
+}
+
+function abort_page(int $status, string $message): never
+{
+ http_response_code($status);
+ $user = auth_user();
+ $title = 'Fehler ' . $status;
+ $content = '';
+ require WS_ROOT . '/views/layout.php';
+ exit;
+}
+
+/** Kürzt Text auf eine Zeichenzahl (mb-safe) und ergänzt eine Ellipse. */
+function shorten(string $text, int $max): string
+{
+ if (mb_strlen($text, 'UTF-8') <= $max) {
+ return $text;
+ }
+ return rtrim(mb_substr($text, 0, $max - 1, 'UTF-8')) . '…';
+}
diff --git a/westreiche_website/assets/app.css b/westreiche_website/assets/app.css
new file mode 100644
index 0000000..05a0c38
--- /dev/null
+++ b/westreiche_website/assets/app.css
@@ -0,0 +1,889 @@
+/* ==========================================================================
+ Westreiche – Charakterverwalter
+ Fantasy-Theme in Nachtblau, Schwarz und Gold (analog zauberturm.de)
+ ========================================================================== */
+
+:root {
+ --night: #0a0d16;
+ --night-2: #0f1526;
+ --night-3: #17203a;
+ --night-4: #212c4c;
+ --gold: #c9a227;
+ --gold-bright: #e8c766;
+ --gold-dim: #7a6320;
+ --parchment: #efe3c8;
+ --parchment-dim: #b9ab8e;
+ --ember: #b3542d;
+ --blood: #8d2f2f;
+ --moss: #3f7f5f;
+ --shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
+ --font-display: "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;
+ --font-body: "EB Garamond", Georgia, "Iowan Old Style", "Palatino Linotype", serif;
+ --radius: 10px;
+}
+
+* { box-sizing: border-box; }
+
+html { scroll-behavior: smooth; }
+
+body {
+ margin: 0;
+ min-height: 100vh;
+ color: var(--parchment);
+ font-family: var(--font-body);
+ font-size: clamp(1.02rem, 0.96rem + 0.28vw, 1.16rem);
+ line-height: 1.65;
+ background-color: var(--night);
+ background-image:
+ radial-gradient(ellipse at 50% -12%, rgba(201, 162, 39, 0.18), transparent 62%),
+ radial-gradient(ellipse at 8% 18%, rgba(47, 82, 160, 0.20), transparent 55%),
+ radial-gradient(ellipse at 92% 72%, rgba(120, 60, 30, 0.14), transparent 58%);
+ background-attachment: fixed;
+}
+
+/* Sternenstaub */
+body::before {
+ content: "";
+ position: fixed;
+ inset: 0;
+ pointer-events: none;
+ opacity: 0.32;
+ background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
+ background-size: 3px 3px;
+ mix-blend-mode: screen;
+ z-index: 0;
+ animation: star-drift 90s linear infinite;
+}
+
+@keyframes star-drift {
+ from { background-position: 0 0; }
+ to { background-position: 240px 480px; }
+}
+
+/* Glutfunken im Hintergrund */
+.embers {
+ position: fixed;
+ inset: 0;
+ pointer-events: none;
+ z-index: 0;
+ overflow: hidden;
+}
+.embers span {
+ position: absolute;
+ bottom: -12vh;
+ width: 3px;
+ height: 3px;
+ border-radius: 50%;
+ background: radial-gradient(circle, var(--gold-bright), rgba(232, 199, 102, 0));
+ box-shadow: 0 0 8px rgba(232, 199, 102, 0.8);
+ animation: ember-rise linear infinite;
+ opacity: 0;
+}
+.embers span:nth-child(1) { left: 6%; animation-duration: 17s; animation-delay: 1s; }
+.embers span:nth-child(2) { left: 18%; animation-duration: 23s; animation-delay: 5s; }
+.embers span:nth-child(3) { left: 31%; animation-duration: 19s; animation-delay: 9s; }
+.embers span:nth-child(4) { left: 44%; animation-duration: 27s; animation-delay: 3s; }
+.embers span:nth-child(5) { left: 57%; animation-duration: 21s; animation-delay: 12s; }
+.embers span:nth-child(6) { left: 68%; animation-duration: 25s; animation-delay: 7s; }
+.embers span:nth-child(7) { left: 79%; animation-duration: 18s; animation-delay: 14s; }
+.embers span:nth-child(8) { left: 91%; animation-duration: 24s; animation-delay: 10s; }
+
+@keyframes ember-rise {
+ 0% { transform: translateY(0) scale(0.7); opacity: 0; }
+ 12% { opacity: 0.9; }
+ 70% { opacity: 0.5; }
+ 100% { transform: translateY(-118vh) scale(1.15); opacity: 0; }
+}
+
+::selection { background: rgba(201, 162, 39, 0.35); color: #fff8e2; }
+
+a { color: var(--gold-bright); text-decoration: none; }
+a:hover { color: #fff3c9; text-decoration: underline; text-underline-offset: 3px; }
+
+h1, h2, h3, h4 {
+ font-family: var(--font-display);
+ font-weight: 600;
+ letter-spacing: 0.05em;
+ color: var(--gold-bright);
+ line-height: 1.22;
+ margin: 0 0 0.5em;
+}
+h1 { font-size: clamp(1.7rem, 3vw, 2.4rem); }
+h2 { font-size: clamp(1.25rem, 2vw, 1.6rem); }
+h3 { font-size: 1.1rem; color: var(--parchment); }
+
+p { margin: 0 0 0.9em; }
+small, .muted { color: var(--parchment-dim); }
+
+.skip-link {
+ position: absolute;
+ left: -9999px;
+ top: 0;
+ background: var(--gold);
+ color: var(--night);
+ padding: 0.6rem 1rem;
+ z-index: 50;
+}
+.skip-link:focus { left: 1rem; top: 1rem; }
+
+/* ------------------------------------------------------------------ Layout */
+
+.shell {
+ position: relative;
+ z-index: 1;
+ max-width: 1180px;
+ margin: 0 auto;
+ padding: 0 1.15rem 4rem;
+}
+
+.topbar {
+ position: sticky;
+ top: 0;
+ z-index: 20;
+ backdrop-filter: blur(10px);
+ background: linear-gradient(180deg, rgba(10, 13, 22, 0.94), rgba(10, 13, 22, 0.72));
+ border-bottom: 1px solid rgba(201, 162, 39, 0.28);
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
+}
+.topbar-inner {
+ max-width: 1180px;
+ margin: 0 auto;
+ padding: 0.6rem 1.15rem;
+ display: flex;
+ align-items: center;
+ gap: 1rem;
+ flex-wrap: wrap;
+}
+
+.brand {
+ display: flex;
+ align-items: center;
+ gap: 0.6rem;
+ font-family: var(--font-display);
+ font-size: 1.12rem;
+ letter-spacing: 0.16em;
+ text-transform: uppercase;
+ color: var(--gold-bright);
+}
+.brand:hover { text-decoration: none; }
+.brand-crest {
+ width: 34px;
+ height: 38px;
+ flex: 0 0 auto;
+ filter: drop-shadow(0 0 6px rgba(201, 162, 39, 0.45));
+ animation: crest-glow 6s ease-in-out infinite;
+}
+@keyframes crest-glow {
+ 0%, 100% { filter: drop-shadow(0 0 5px rgba(201, 162, 39, 0.35)); }
+ 50% { filter: drop-shadow(0 0 14px rgba(232, 199, 102, 0.75)); }
+}
+.brand small {
+ display: block;
+ font-family: var(--font-body);
+ font-size: 0.66rem;
+ letter-spacing: 0.22em;
+ color: var(--parchment-dim);
+ text-transform: uppercase;
+}
+
+.nav {
+ display: flex;
+ gap: 0.25rem;
+ flex-wrap: wrap;
+ margin-left: auto;
+ align-items: center;
+}
+.nav a,
+.nav button {
+ position: relative;
+ padding: 0.42rem 0.7rem;
+ border-radius: 6px;
+ color: var(--parchment);
+ font-family: var(--font-display);
+ font-size: 0.82rem;
+ letter-spacing: 0.1em;
+ text-transform: uppercase;
+ border: 0;
+ background: none;
+ cursor: pointer;
+}
+.nav a::after {
+ content: "";
+ position: absolute;
+ left: 0.7rem;
+ right: 0.7rem;
+ bottom: 0.22rem;
+ height: 1px;
+ background: linear-gradient(90deg, transparent, var(--gold), transparent);
+ transform: scaleX(0);
+ transition: transform 0.35s ease;
+}
+.nav a:hover::after,
+.nav a[aria-current="page"]::after { transform: scaleX(1); }
+.nav a[aria-current="page"] { color: var(--gold-bright); }
+.nav form { margin: 0; }
+
+main { padding-top: 2rem; }
+
+.page-head {
+ display: flex;
+ align-items: flex-end;
+ justify-content: space-between;
+ gap: 1rem;
+ flex-wrap: wrap;
+ margin-bottom: 1.4rem;
+}
+.page-head .lede { color: var(--parchment-dim); max-width: 60ch; margin: 0; }
+
+/* ------------------------------------------------------------------- Karten */
+
+.panel {
+ position: relative;
+ background: linear-gradient(160deg, rgba(23, 32, 58, 0.92), rgba(10, 13, 22, 0.92));
+ border: 1px solid rgba(201, 162, 39, 0.3);
+ border-radius: var(--radius);
+ padding: 1.3rem 1.35rem;
+ box-shadow: var(--shadow);
+ margin-bottom: 1.6rem;
+ animation: panel-in 0.55s ease both;
+}
+@keyframes panel-in {
+ from { opacity: 0; transform: translateY(14px); }
+ to { opacity: 1; transform: translateY(0); }
+}
+.panel::after {
+ content: "";
+ position: absolute;
+ inset: 5px;
+ border: 1px solid rgba(201, 162, 39, 0.12);
+ border-radius: calc(var(--radius) - 3px);
+ pointer-events: none;
+}
+.panel > * { position: relative; z-index: 1; }
+.panel h2:first-child { margin-top: 0; }
+
+.divider {
+ height: 1px;
+ border: 0;
+ margin: 1.2rem 0;
+ background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.55), transparent);
+}
+
+/* Charakterkarten */
+.card-grid {
+ display: grid;
+ gap: 1.1rem;
+ grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
+}
+.hero-card {
+ position: relative;
+ display: block;
+ padding: 1.1rem 1.2rem 1.15rem;
+ border-radius: var(--radius);
+ border: 1px solid rgba(201, 162, 39, 0.32);
+ background:
+ radial-gradient(circle at 100% 0%, rgba(201, 162, 39, 0.16), transparent 55%),
+ linear-gradient(165deg, rgba(23, 32, 58, 0.96), rgba(10, 13, 22, 0.96));
+ color: var(--parchment);
+ box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
+ transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
+ overflow: hidden;
+ animation: panel-in 0.5s ease both;
+}
+.hero-card::before {
+ content: "";
+ position: absolute;
+ inset: -60% -20%;
+ background: conic-gradient(from 0deg, transparent 0deg, rgba(201, 162, 39, 0.16) 40deg, transparent 90deg);
+ opacity: 0;
+ transition: opacity 0.5s ease;
+ animation: rune-spin 14s linear infinite;
+}
+@keyframes rune-spin {
+ to { transform: rotate(360deg); }
+}
+.hero-card:hover,
+.hero-card:focus-visible {
+ transform: translateY(-6px);
+ border-color: var(--gold);
+ box-shadow: 0 20px 44px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(232, 199, 102, 0.25);
+ text-decoration: none;
+}
+.hero-card:hover::before { opacity: 1; }
+.hero-card > * { position: relative; z-index: 1; }
+
+.hero-card .name {
+ font-family: var(--font-display);
+ font-size: 1.2rem;
+ color: var(--gold-bright);
+ letter-spacing: 0.05em;
+}
+.hero-card .meta { font-size: 0.86rem; color: var(--parchment-dim); letter-spacing: 0.06em; }
+.hero-card .hp-bar {
+ margin-top: 0.85rem;
+ height: 7px;
+ border-radius: 99px;
+ background: rgba(0, 0, 0, 0.55);
+ overflow: hidden;
+ border: 1px solid rgba(201, 162, 39, 0.25);
+}
+.hero-card .hp-bar span {
+ display: block;
+ height: 100%;
+ border-radius: 99px;
+ background: linear-gradient(90deg, var(--moss), var(--gold-bright));
+ transition: width 0.6s ease;
+}
+.hero-card .hp-bar.critical span { background: linear-gradient(90deg, var(--blood), var(--ember)); }
+.hero-card .hp-bar.unconscious span { background: var(--night-4); }
+
+.badge {
+ display: inline-block;
+ padding: 0.12rem 0.55rem;
+ border-radius: 99px;
+ font-size: 0.7rem;
+ letter-spacing: 0.14em;
+ text-transform: uppercase;
+ border: 1px solid rgba(201, 162, 39, 0.45);
+ color: var(--gold-bright);
+ background: rgba(201, 162, 39, 0.08);
+}
+.badge.badge-dead { border-color: rgba(141, 47, 47, 0.7); color: #e39a9a; background: rgba(141, 47, 47, 0.16); }
+.badge.badge-retired { border-color: rgba(185, 171, 142, 0.5); color: var(--parchment-dim); background: rgba(185, 171, 142, 0.1); }
+.badge.badge-admin { border-color: rgba(232, 199, 102, 0.8); color: #fff2c8; }
+
+/* ---------------------------------------------------------------- Formulare */
+
+.btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.45rem;
+ padding: 0.55rem 1.05rem;
+ border-radius: 8px;
+ font-family: var(--font-display);
+ font-size: 0.82rem;
+ letter-spacing: 0.12em;
+ text-transform: uppercase;
+ border: 1px solid rgba(201, 162, 39, 0.5);
+ color: var(--gold-bright);
+ background: linear-gradient(180deg, rgba(201, 162, 39, 0.14), rgba(201, 162, 39, 0.04));
+ cursor: pointer;
+ transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.25s ease;
+}
+.btn:hover {
+ text-decoration: none;
+ transform: translateY(-1px);
+ box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(232, 199, 102, 0.35);
+ background: linear-gradient(180deg, rgba(201, 162, 39, 0.24), rgba(201, 162, 39, 0.08));
+}
+.btn-primary {
+ background: linear-gradient(180deg, var(--gold-bright), var(--gold));
+ color: #1a1405;
+ border-color: #f0d98d;
+ font-weight: 600;
+}
+.btn-primary:hover { background: linear-gradient(180deg, #f6e2a4, var(--gold-bright)); }
+.btn-ghost { border-color: rgba(185, 171, 142, 0.35); color: var(--parchment); background: none; }
+.btn-danger { border-color: rgba(141, 47, 47, 0.7); color: #f0b3b3; background: rgba(141, 47, 47, 0.14); }
+.btn-small { padding: 0.3rem 0.6rem; font-size: 0.72rem; }
+
+.form-grid { display: grid; gap: 0.9rem; }
+.grid-2 { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
+.grid-3 { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
+.grid-4 { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
+
+.field { display: grid; gap: 0.3rem; }
+.field > span {
+ font-family: var(--font-display);
+ font-size: 0.72rem;
+ letter-spacing: 0.16em;
+ text-transform: uppercase;
+ color: var(--parchment-dim);
+}
+input[type="text"], input[type="email"], input[type="password"], input[type="number"],
+input[type="search"], select, textarea {
+ width: 100%;
+ padding: 0.5rem 0.65rem;
+ border-radius: 7px;
+ border: 1px solid rgba(201, 162, 39, 0.3);
+ background: rgba(6, 9, 16, 0.75);
+ color: var(--parchment);
+ font-family: var(--font-body);
+ font-size: 1rem;
+ transition: border-color 0.25s ease, box-shadow 0.25s ease;
+}
+input:focus, select:focus, textarea:focus {
+ outline: none;
+ border-color: var(--gold);
+ box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
+}
+textarea { min-height: 6.5rem; resize: vertical; }
+select option { background: var(--night-2); }
+input[type="checkbox"] { accent-color: var(--gold); width: 16px; height: 16px; }
+
+/* Zahlenfelder ohne hoch/runter-Pfeile (werden am Tisch nicht gebraucht) */
+input[type="number"] {
+ -moz-appearance: textfield;
+ appearance: textfield;
+}
+input[type="number"]::-webkit-outer-spin-button,
+input[type="number"]::-webkit-inner-spin-button {
+ -webkit-appearance: none;
+ margin: 0;
+}
+
+.visually-quiet {
+ font-size: 0.6rem;
+ letter-spacing: 0.12em;
+ opacity: 0.65;
+}
+
+.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 1.1rem; }
+
+.alert {
+ padding: 0.6rem 0.9rem;
+ border-radius: 8px;
+ border: 1px solid;
+ margin: 0 0 1rem;
+ animation: panel-in 0.35s ease both;
+}
+.alert-error { border-color: rgba(141, 47, 47, 0.75); background: rgba(141, 47, 47, 0.16); color: #f4c4c4; }
+.alert-success { border-color: rgba(63, 127, 95, 0.7); background: rgba(63, 127, 95, 0.16); color: #c9eed8; }
+.alert-info { border-color: rgba(201, 162, 39, 0.55); background: rgba(201, 162, 39, 0.1); color: #f2e4bd; }
+
+/* ------------------------------------------------------------------ Tabellen */
+
+table.data {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: 0.95rem;
+}
+table.data th {
+ text-align: left;
+ font-family: var(--font-display);
+ font-size: 0.7rem;
+ letter-spacing: 0.14em;
+ text-transform: uppercase;
+ color: var(--parchment-dim);
+ border-bottom: 1px solid rgba(201, 162, 39, 0.35);
+ padding: 0.4rem 0.5rem;
+}
+table.data td {
+ padding: 0.45rem 0.5rem;
+ border-bottom: 1px solid rgba(201, 162, 39, 0.12);
+ vertical-align: top;
+}
+table.data tr:hover td { background: rgba(201, 162, 39, 0.05); }
+table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
+
+.inline-form { display: flex; gap: 0.45rem; align-items: flex-end; flex-wrap: wrap; }
+.inline-form .field { min-width: 120px; }
+.inline-form .field.grow { flex: 1 1 180px; }
+
+/* ------------------------------------------------------------- Charakterbogen */
+
+.sheet-head {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ gap: 1rem;
+ align-items: start;
+}
+.monogram {
+ width: 92px;
+ height: 92px;
+ display: grid;
+ place-items: center;
+ border: 1px solid rgba(201, 162, 39, 0.6);
+ border-radius: 50%;
+ font-family: var(--font-display);
+ font-size: 2.4rem;
+ color: var(--gold-bright);
+ box-shadow: inset 0 0 22px rgba(201, 162, 39, 0.18), 0 0 26px rgba(201, 162, 39, 0.16);
+ animation: crest-glow 7s ease-in-out infinite;
+}
+
+.stat-row {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
+ gap: 0.6rem;
+}
+.stat {
+ position: relative;
+ padding: 0.55rem 0.5rem;
+ text-align: center;
+ border-radius: 8px;
+ border: 1px solid rgba(201, 162, 39, 0.35);
+ background: rgba(6, 9, 16, 0.55);
+}
+.stat .k {
+ display: block;
+ font-family: var(--font-display);
+ font-size: 0.62rem;
+ letter-spacing: 0.16em;
+ text-transform: uppercase;
+ color: var(--parchment-dim);
+}
+.stat .v {
+ display: block;
+ font-family: var(--font-display);
+ font-size: 1.5rem;
+ color: var(--gold-bright);
+}
+.stat .b { display: block; font-size: 0.72rem; color: var(--ember); }
+
+.tabs {
+ display: flex;
+ gap: 0.3rem;
+ flex-wrap: wrap;
+ border-bottom: 1px solid rgba(201, 162, 39, 0.28);
+ margin-bottom: 1.1rem;
+}
+.tabs a {
+ padding: 0.45rem 0.8rem;
+ font-family: var(--font-display);
+ font-size: 0.76rem;
+ letter-spacing: 0.12em;
+ text-transform: uppercase;
+ color: var(--parchment-dim);
+ border-bottom: 2px solid transparent;
+}
+.tabs a:hover { color: var(--gold-bright); text-decoration: none; border-bottom-color: rgba(201, 162, 39, 0.5); }
+
+.pill-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
+.pill {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.35rem;
+ padding: 0.2rem 0.6rem;
+ border-radius: 99px;
+ border: 1px solid rgba(201, 162, 39, 0.35);
+ background: rgba(201, 162, 39, 0.08);
+ font-size: 0.85rem;
+}
+.pill form { margin: 0; }
+.pill button {
+ border: 0;
+ background: none;
+ color: var(--parchment-dim);
+ font-size: 0.78rem;
+ cursor: pointer;
+ padding: 0 0.15rem;
+}
+.pill button:hover { color: #ffd7d7; }
+
+.grade-block { margin-bottom: 0.9rem; }
+.grade-block h4 {
+ margin: 0 0 0.35rem;
+ font-size: 0.72rem;
+ letter-spacing: 0.16em;
+ text-transform: uppercase;
+ color: var(--gold);
+}
+
+/* ------------------------------------------------------------------ Login */
+
+.auth-shell {
+ min-height: 100vh;
+ display: grid;
+ place-items: center;
+ padding: 2rem 1.1rem;
+}
+.auth-card {
+ position: relative;
+ z-index: 1;
+ width: min(460px, 100%);
+ padding: 2rem 1.9rem 1.8rem;
+ border-radius: 14px;
+ border: 1px solid rgba(201, 162, 39, 0.45);
+ background: linear-gradient(165deg, rgba(23, 32, 58, 0.96), rgba(6, 9, 16, 0.98));
+ box-shadow: 0 30px 60px rgba(0, 0, 0, 0.65), inset 0 0 40px rgba(201, 162, 39, 0.06);
+ animation: panel-in 0.6s ease both;
+}
+.auth-card::after {
+ content: "";
+ position: absolute;
+ inset: 7px;
+ border: 1px solid rgba(201, 162, 39, 0.16);
+ border-radius: 10px;
+ pointer-events: none;
+}
+.brand-kicker {
+ font-family: var(--font-display);
+ font-size: 0.72rem;
+ letter-spacing: 0.42em;
+ text-transform: uppercase;
+ color: var(--gold);
+ margin: 0 0 0.3rem;
+}
+.auth-card h1 { margin-bottom: 1rem; }
+.auth-card .btn-primary { justify-content: center; width: 100%; }
+.auth-links { margin-top: 1.1rem; font-size: 0.86rem; color: var(--parchment-dim); }
+.auth-stars {
+ position: fixed;
+ inset: 0;
+ pointer-events: none;
+ background-image:
+ radial-gradient(1.5px 1.5px at 20% 30%, rgba(255, 255, 255, 0.55), transparent),
+ radial-gradient(1.5px 1.5px at 70% 15%, rgba(232, 199, 102, 0.6), transparent),
+ radial-gradient(1px 1px at 40% 70%, rgba(255, 255, 255, 0.4), transparent),
+ radial-gradient(1.5px 1.5px at 85% 60%, rgba(255, 255, 255, 0.35), transparent),
+ radial-gradient(1px 1px at 12% 85%, rgba(232, 199, 102, 0.5), transparent);
+ animation: twinkle 8s ease-in-out infinite alternate;
+}
+@keyframes twinkle {
+ from { opacity: 0.5; }
+ to { opacity: 1; }
+}
+
+.empty-state {
+ text-align: center;
+ padding: 3rem 1rem;
+ color: var(--parchment-dim);
+}
+.empty-state .rune {
+ display: block;
+ margin: 0 auto 0.8rem;
+ width: 54px;
+ height: 54px;
+ border: 1px solid rgba(201, 162, 39, 0.45);
+ border-radius: 50%;
+ display: grid;
+ place-items: center;
+ font-family: var(--font-display);
+ font-size: 1.4rem;
+ color: var(--gold-bright);
+ animation: rune-pulse 3.4s ease-in-out infinite;
+}
+@keyframes rune-pulse {
+ 0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.3); }
+ 50% { box-shadow: 0 0 22px 4px rgba(201, 162, 39, 0.18); }
+}
+
+.footer {
+ position: relative;
+ z-index: 1;
+ text-align: center;
+ padding: 2.4rem 1rem 2rem;
+ font-size: 0.82rem;
+ color: var(--parchment-dim);
+ border-top: 1px solid rgba(201, 162, 39, 0.18);
+}
+.footer a { color: var(--gold); }
+
+.copy-box {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ flex-wrap: wrap;
+ padding: 0.6rem 0.7rem;
+ border-radius: 8px;
+ border: 1px dashed rgba(201, 162, 39, 0.5);
+ background: rgba(201, 162, 39, 0.06);
+ word-break: break-all;
+ font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
+ font-size: 0.82rem;
+}
+
+.imprint { font-size: 0.86rem; color: var(--parchment-dim); }
+
+@media (max-width: 620px) {
+ .sheet-head { grid-template-columns: 1fr; }
+ .monogram { width: 64px; height: 64px; font-size: 1.7rem; }
+ .topbar-inner { gap: 0.5rem; }
+ .nav { margin-left: 0; width: 100%; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ *, *::before, *::after {
+ animation-duration: 0.001ms !important;
+ animation-iteration-count: 1 !important;
+ transition-duration: 0.001ms !important;
+ }
+ .embers { display: none; }
+}
+
+@media print {
+ .topbar, .nav, .footer, .embers, .actions, .tabs { display: none !important; }
+ body { background: #fff; color: #111; }
+ .panel { box-shadow: none; border-color: #bbb; background: #fff; }
+}
+
+/* --------------------------------------------------------------- Porträts */
+
+.portrait-frame {
+ width: clamp(150px, 26vw, 210px);
+ aspect-ratio: 3 / 4;
+ object-fit: cover;
+ object-position: 50% 22%;
+ border-radius: 8px;
+ border: 1px solid rgba(201, 162, 39, 0.65);
+ box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6), 0 0 0 5px rgba(201, 162, 39, 0.08);
+ filter: saturate(1.05) contrast(1.03);
+ animation: portrait-in 0.7s ease both;
+}
+@keyframes portrait-in {
+ from { opacity: 0; transform: scale(0.96) translateY(8px); }
+ to { opacity: 1; transform: none; }
+}
+
+.hero-thumb {
+ width: 46px;
+ height: 46px;
+ border-radius: 50%;
+ object-fit: cover;
+ object-position: 50% 20%;
+ border: 1px solid rgba(201, 162, 39, 0.6);
+ box-shadow: 0 0 14px rgba(201, 162, 39, 0.22);
+ flex: 0 0 auto;
+}
+
+.portrait-editor {
+ display: grid;
+ grid-template-columns: auto 1fr;
+ gap: 1.2rem;
+ align-items: start;
+}
+.portrait-thumb {
+ width: 120px;
+ aspect-ratio: 3 / 4;
+ object-fit: cover;
+ object-position: 50% 22%;
+ border-radius: 6px;
+ border: 1px solid rgba(201, 162, 39, 0.5);
+}
+input[type="file"] {
+ padding: 0.45rem;
+ border-radius: 7px;
+ border: 1px dashed rgba(201, 162, 39, 0.45);
+ background: rgba(6, 9, 16, 0.6);
+ color: var(--parchment-dim);
+ font-size: 0.9rem;
+}
+@media (max-width: 620px) {
+ .portrait-editor { grid-template-columns: 1fr; }
+}
+
+/* Fertigkeitengruppen wie auf dem Charakterbogen */
+.skill-group {
+ margin: 1.4rem 0 0.4rem;
+ font-size: 0.74rem;
+ letter-spacing: 0.24em;
+ text-transform: uppercase;
+ color: var(--gold);
+ border-bottom: 1px solid rgba(201, 162, 39, 0.35);
+ padding-bottom: 0.3rem;
+}
+.skill-group:first-of-type { margin-top: 0.6rem; }
+.skill-table td.skill-name { min-width: 12rem; white-space: nowrap; }
+.skill-table th.num, .skill-table td.num { width: 4.5rem; }
+
+/* --- Boni: positiv grün, null grau, negativ rot ------------------------- */
+.bonus-pos { color: #79d29a; }
+.bonus-zero { color: var(--parchment-dim); }
+.bonus-neg { color: #e0756a; }
+.stat .b.bonus-pos { color: #79d29a; }
+.stat .b.bonus-zero { color: var(--parchment-dim); }
+.stat .b.bonus-neg { color: #e0756a; }
+
+/* --- Selektor-Schirm für Fertigkeiten und Zauber ------------------------ */
+.selector-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
+
+dialog.selector {
+ width: min(46rem, 94vw);
+ max-height: 86vh;
+ padding: 0;
+ border: 1px solid rgba(201, 162, 39, 0.45);
+ border-radius: var(--radius);
+ background: linear-gradient(160deg, var(--night-2), var(--night));
+ color: var(--parchment);
+ box-shadow: var(--shadow);
+}
+dialog.selector::backdrop { background: rgba(4, 6, 12, 0.72); backdrop-filter: blur(2px); }
+.selector-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 1rem;
+ padding: 0.9rem 1.1rem;
+ border-bottom: 1px solid rgba(201, 162, 39, 0.28);
+ background: rgba(6, 9, 16, 0.6);
+ position: sticky;
+ top: 0;
+ z-index: 2;
+}
+.selector-head h2 { margin: 0; font-size: 1.05rem; color: var(--gold-bright); }
+.selector-body { padding: 0.9rem 1.1rem 1.2rem; overflow-y: auto; max-height: calc(86vh - 4rem); }
+.selector-filters { display: grid; grid-template-columns: 1fr; gap: 0.5rem; margin-bottom: 0.8rem; }
+@media (min-width: 40rem) {
+ .selector-filters { grid-template-columns: 1fr auto auto; align-items: end; }
+}
+.selector-filters .field { margin: 0; }
+.selector-group { margin: 0.9rem 0 0.35rem; font-size: 0.8rem; letter-spacing: 0.14em;
+ text-transform: uppercase; color: var(--gold-dim); }
+.selector-groups .selector-group:first-child { margin-top: 0; }
+.selector-item {
+ display: flex;
+ align-items: baseline;
+ justify-content: space-between;
+ gap: 0.6rem;
+ width: 100%;
+ padding: 0.42rem 0.6rem;
+ margin: 0 0 0.25rem;
+ font: inherit;
+ text-align: left;
+ color: var(--parchment);
+ background: rgba(23, 32, 58, 0.55);
+ border: 1px solid rgba(201, 162, 39, 0.18);
+ border-radius: 7px;
+ cursor: pointer;
+ transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
+}
+.selector-item:hover,
+.selector-item:focus-visible {
+ border-color: var(--gold);
+ background: rgba(201, 162, 39, 0.16);
+ transform: translateX(2px);
+ outline: none;
+}
+.selector-item .meta { font-size: 0.75rem; color: var(--parchment-dim); white-space: nowrap; }
+.selector-item[hidden] { display: none; }
+.selector-empty { color: var(--parchment-dim); font-style: italic; }
+.selector-custom { margin-top: 1rem; border-top: 1px solid rgba(201, 162, 39, 0.28); padding-top: 0.7rem; }
+.selector-custom summary { cursor: pointer; color: var(--gold); font-size: 0.9rem; }
+.selector-custom .inline-form { margin-top: 0.6rem; }
+
+/* --- Zauberdetails im Bogen -------------------------------------------- */
+.pill.pill-detail {
+ font: inherit;
+ font-size: 0.85rem;
+ color: var(--parchment);
+ cursor: pointer;
+ transition: border-color 0.15s ease, background 0.15s ease;
+}
+.pill.pill-detail:hover,
+.pill.pill-detail:focus-visible {
+ border-color: var(--gold);
+ background: rgba(201, 162, 39, 0.18);
+ outline: none;
+}
+.spell-detail .selector-body { max-height: calc(86vh - 4rem); }
+.detail-list {
+ display: grid;
+ grid-template-columns: minmax(8rem, max-content) 1fr;
+ gap: 0.3rem 0.9rem;
+ margin: 0 0 1rem;
+}
+.detail-list dt {
+ color: var(--gold-dim);
+ font-size: 0.78rem;
+ letter-spacing: 0.1em;
+ text-transform: uppercase;
+}
+.detail-list dd { margin: 0; }
+
+.spell-body {
+ white-space: pre-line;
+ line-height: 1.55;
+ color: var(--parchment);
+}
+.spell-body:not(:empty) { margin-top: 0.2rem; }
diff --git a/westreiche_website/assets/app.js b/westreiche_website/assets/app.js
new file mode 100644
index 0000000..359c862
--- /dev/null
+++ b/westreiche_website/assets/app.js
@@ -0,0 +1,185 @@
+/* Westreiche – wenig JavaScript, nur Komfort. */
+(function () {
+ 'use strict';
+
+ // Löschbestätigungen über data-confirm
+ document.addEventListener('click', function (event) {
+ const trigger = event.target.closest('[data-confirm]');
+ if (!trigger) {
+ return;
+ }
+ if (!window.confirm(trigger.getAttribute('data-confirm'))) {
+ event.preventDefault();
+ }
+ });
+
+ // Einladungslink kopieren
+ document.querySelectorAll('[data-copy]').forEach(function (button) {
+ button.addEventListener('click', async function () {
+ const target = document.querySelector(button.getAttribute('data-copy'));
+ if (!target) {
+ return;
+ }
+ const text = (target.textContent || '').trim();
+ try {
+ await navigator.clipboard.writeText(text);
+ const label = button.textContent;
+ button.textContent = 'Kopiert';
+ setTimeout(function () {
+ button.textContent = label;
+ }, 1800);
+ } catch (error) {
+ window.prompt('Link kopieren:', text);
+ }
+ });
+ });
+
+ // Attributboni live anzeigen
+ const bonus = function (value) {
+ if (value <= 3) return -3;
+ if (value <= 5) return -2;
+ if (value <= 8) return -1;
+ if (value <= 12) return 0;
+ if (value <= 15) return 1;
+ if (value <= 17) return 2;
+ return 3;
+ };
+ document.querySelectorAll('[data-attr]').forEach(function (input) {
+ const out = document.querySelector('[data-attr-bonus="' + input.name + '"]');
+ if (!out) {
+ return;
+ }
+ const update = function () {
+ const value = parseInt(input.value, 10) || 0;
+ const b = bonus(value);
+ out.textContent = b > 0 ? '+' + b : String(b);
+ out.classList.toggle('bonus-pos', b > 0);
+ out.classList.toggle('bonus-neg', b < 0);
+ out.classList.toggle('bonus-zero', b === 0);
+ };
+ input.addEventListener('input', update);
+ update();
+ });
+
+ // Zauberdetails im Bogen: Klick auf den Namen füllt den Detail-Schirm
+ const spellDetail = document.querySelector('#spell-detail');
+ if (spellDetail) {
+ const fields = ['name', 'line', 'classes', 'duration', 'range', 'note', 'summary', 'body'];
+ document.querySelectorAll('[data-spell-detail]').forEach(function (button) {
+ button.addEventListener('click', function () {
+ fields.forEach(function (key) {
+ const out = spellDetail.querySelector('[data-spell-field="' + key + '"]');
+ if (!out) {
+ return;
+ }
+ const value = (button.getAttribute('data-' + key) || '').trim();
+ out.textContent = value !== '' ? value : (key === 'body' || key === 'summary' ? '' : '–');
+ if (key === 'summary' || key === 'body') {
+ out.hidden = value === '';
+ }
+ });
+ const empty = spellDetail.querySelector('[data-spell-field="empty"]');
+ if (empty) {
+ const hasCatalog = (button.getAttribute('data-body') || '').trim() !== ''
+ || (button.getAttribute('data-summary') || '').trim() !== ''
+ || (button.getAttribute('data-duration') || '').trim() !== ''
+ || (button.getAttribute('data-range') || '').trim() !== '';
+ empty.hidden = hasCatalog;
+ }
+ if (typeof spellDetail.showModal === 'function' && !spellDetail.open) {
+ spellDetail.showModal();
+ }
+ });
+ });
+ }
+
+ // Selektor-Schirme: Fertigkeiten und Zauber aus dem Katalog wählen
+ // Blendet Überschriften aus, wenn keine ihrer Einträge sichtbar ist.
+ const hideEmptyGroups = function (dialog) {
+ dialog.querySelectorAll('.selector-group').forEach(function (heading) {
+ let node = heading.nextElementSibling;
+ let anyVisible = false;
+ while (node && !node.classList.contains('selector-group')) {
+ if (node.hasAttribute('data-selector-item') && !node.hidden) {
+ anyVisible = true;
+ break;
+ }
+ node = node.nextElementSibling;
+ }
+ heading.hidden = !anyVisible;
+ });
+ };
+
+ const filterSelector = function (dialog) {
+ const search = dialog.querySelector('[data-selector-search]');
+ const school = dialog.querySelector('[data-selector-school]');
+ const grade = dialog.querySelector('[data-selector-grade]');
+ const query = search ? search.value.trim().toLowerCase() : '';
+ const wantSchool = school ? school.value : '';
+ const wantGrade = grade ? grade.value : '';
+ let visible = 0;
+
+ dialog.querySelectorAll('[data-selector-item]').forEach(function (item) {
+ const name = item.getAttribute('data-name') || '';
+ const matches = (!query || name.indexOf(query) !== -1)
+ && (!wantSchool || item.getAttribute('data-school') === wantSchool)
+ && (!wantGrade || item.getAttribute('data-grade') === wantGrade);
+ item.hidden = !matches;
+ if (matches) {
+ visible++;
+ }
+ });
+
+ const empty = dialog.querySelector('[data-selector-empty]');
+ if (empty) {
+ empty.hidden = visible !== 0;
+ }
+ hideEmptyGroups(dialog);
+ };
+
+ document.querySelectorAll('[data-dialog-open]').forEach(function (button) {
+ button.addEventListener('click', function () {
+ const dialog = document.querySelector(button.getAttribute('data-dialog-open'));
+ if (!dialog || typeof dialog.showModal !== 'function' || dialog.open) {
+ return;
+ }
+ dialog.showModal();
+ const search = dialog.querySelector('[data-selector-search]');
+ if (search) {
+ search.value = '';
+ }
+ dialog.querySelectorAll('select[data-selector-school], select[data-selector-grade]').forEach(function (select) {
+ select.selectedIndex = 0;
+ });
+ filterSelector(dialog);
+ if (search) {
+ search.focus();
+ }
+ });
+ });
+
+ document.querySelectorAll('dialog.selector').forEach(function (dialog) {
+ dialog.addEventListener('click', function (event) {
+ // Klick auf den Hintergrund (nicht auf den Inhalt) schließt den Schirm
+ if (event.target === dialog) {
+ dialog.close();
+ }
+ });
+ dialog.querySelectorAll('[data-dialog-close]').forEach(function (button) {
+ button.addEventListener('click', function () {
+ dialog.close();
+ });
+ });
+ const search = dialog.querySelector('[data-selector-search]');
+ if (search) {
+ search.addEventListener('input', function () {
+ filterSelector(dialog);
+ });
+ }
+ dialog.querySelectorAll('[data-selector-school], [data-selector-grade]').forEach(function (select) {
+ select.addEventListener('change', function () {
+ filterSelector(dialog);
+ });
+ });
+ });
+})();
diff --git a/westreiche_website/assets/crest.svg b/westreiche_website/assets/crest.svg
new file mode 100644
index 0000000..f13b26f
--- /dev/null
+++ b/westreiche_website/assets/crest.svg
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/westreiche_website/assets/portraits/assassine.webp b/westreiche_website/assets/portraits/assassine.webp
new file mode 100644
index 0000000000000000000000000000000000000000..16cef61b8c326af592ed374c07ec99470e608cf8
GIT binary patch
literal 37348
zcmV(tK)(|v{HP&_^fq9Nl#|NL%EpKf}dVY{rdViZaM}FX(>_
z{5tzmJqHH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