= htmlspecialchars($t['title'], ENT_QUOTES) ?>
+= nl2br(htmlspecialchars(substr($t['body'], 0, 200), ENT_QUOTES)) ?>= strlen($t['body']) > 200 ? '…' : '' ?>
+diff --git a/partials/landing/community/index.php b/partials/landing/community/index.php
new file mode 100644
index 0000000..4683300
--- /dev/null
+++ b/partials/landing/community/index.php
@@ -0,0 +1,125 @@
+pdo();
+$userId = $_SESSION['user_id'] ?? null;
+$error = '';
+$search = trim((string)($_GET['q'] ?? ''));
+
+$communityCfg = require __DIR__ . '/../../../config/community.php';
+$community = $pdo ? new \App\Community($pdo, $communityCfg) : null;
+
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'thread_create') {
+ if (!$userId) {
+ $error = 'Bitte einloggen, um Fragen zu stellen.';
+ } elseif ($community) {
+ $title = trim((string)($_POST['title'] ?? ''));
+ $body = trim((string)($_POST['body'] ?? ''));
+ if ($title === '' || $body === '') {
+ $error = 'Titel und Text sind erforderlich.';
+ } else {
+ $community->createThread((int)$userId, $title, $body);
+ redirect('/community');
+ }
+ }
+}
+
+$threads = $community ? ($search !== '' ? $community->searchThreads($search, 50) : $community->listThreads(50)) : [];
+?>
+ Community = nl2br(htmlspecialchars(substr($t['body'], 0, 200), ENT_QUOTES)) ?>= strlen($t['body']) > 200 ? '…' : '' ?> Keine Treffer.Forum
+
+
+
+
+ = htmlspecialchars($t['title'], ENT_QUOTES) ?>
+
Thread nicht gefunden.
"; + return; +} +?> +Community
+Von = htmlspecialchars($thread['display_name'] ?: 'Mitglied', ENT_QUOTES) ?> · = htmlspecialchars($thread['created_at'], ENT_QUOTES) ?>
+= nl2br(htmlspecialchars($thread['body'], ENT_QUOTES)) ?>
+= nl2br(htmlspecialchars($p['body'], ENT_QUOTES)) ?>
+Noch keine Antworten.
+ +Bitte einloggen, um zu antworten.
+ +Community
-= nl2br(htmlspecialchars(substr($t['body'], 0, 200), ENT_QUOTES)) ?>= strlen($t['body']) > 200 ? '…' : '' ?>
-Noch keine Fragen gestellt.
- -Thread nicht gefunden.
'); -} - -if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'reply') { - if (!$userId) { - $error = 'Bitte einloggen, um zu antworten.'; - } elseif ($pdo) { - $body = trim((string)($_POST['body'] ?? '')); - if ($body === '') { - $error = 'Antwort darf nicht leer sein.'; - } else { - $pdo->prepare('INSERT INTO forum_posts (thread_id, user_id, body) VALUES (:tid, :uid, :body)') - ->execute(['tid' => $id, 'uid' => $userId, 'body' => $body]); - header('Location: /community_thread?id=' . $id); - exit; - } - } -} - -$thread = null; -$posts = []; -if ($pdo) { - $stmt = $pdo->prepare('SELECT ft.*, p.display_name FROM forum_threads ft LEFT JOIN user_profiles p ON p.user_id = ft.user_id WHERE ft.id = :id'); - $stmt->execute(['id' => $id]); - $thread = $stmt->fetch(PDO::FETCH_ASSOC); - if ($thread) { - $stmt = $pdo->prepare('SELECT fp.*, p.display_name FROM forum_posts fp LEFT JOIN user_profiles p ON p.user_id = fp.user_id WHERE fp.thread_id = :id ORDER BY fp.created_at ASC'); - $stmt->execute(['id' => $id]); - $posts = $stmt->fetchAll(PDO::FETCH_ASSOC) ?: []; - } -} - -if (!$thread) { - http_response_code(404); - exit('Thread nicht gefunden.
'); -} -?> -Community
-Von = htmlspecialchars($thread['display_name'] ?: 'Mitglied', ENT_QUOTES) ?> · = htmlspecialchars($thread['created_at'], ENT_QUOTES) ?>
-= nl2br(htmlspecialchars($thread['body'], ENT_QUOTES)) ?>
-= nl2br(htmlspecialchars($p['body'], ENT_QUOTES)) ?>
-Noch keine Antworten.
- -Bitte einloggen, um zu antworten.
- -