showthread($do[1], $do[2]), 'new' => newthread(), 'reply' => reply(), 'list' => donothing($do[1]), default => donothing() }; function donothing($start = 0) { $query = db()->query('SELECT * FROM forum WHERE parent=0 ORDER BY newpostdate DESC LIMIT 20 OFFSET ?;', [20 * $start]); $page = "
\n"; $hasRows = false; while ($row = $query->fetchArray(SQLITE3_ASSOC)) { $hasRows = true; $page .= "\n"; } if (!$hasRows) { $page .= "\n"; } $page .= "
New Thread
ThreadRepliesLast Post
".$row["title"]."".$row["replies"]."".$row["newpostdate"]."
No threads in forum.
"; display($page, "Forum"); } function showthread($id, $start) { $posts = db()->query('SELECT * FROM forum WHERE id=? OR parent=? ORDER BY id LIMIT 15 OFFSET ?;', [$id, $id, $start * 15]); $title = db()->query('SELECT title FROM forum WHERE id=? LIMIT 1;', [$id])->fetchArray(SQLITE3_ASSOC); $page = "
\n"; while ($row = $posts->fetchArray(SQLITE3_ASSOC)) { $page .= "\n"; } $page .= "
Forum :: ".$title['title']."
".$row["author"]."

".prettyforumdate($row["postdate"])."
".nl2br($row["content"])."

"; $page .= "
Reply To This Thread:

"; display($page, "Forum"); } function reply() { global $userrow; $p = $_POST['parent'] ?? 0; $t = trim($_POST['title'] ?? ''); $c = trim($_POST['content'] ?? ''); db()->query('INSERT INTO forum (author, title, content, parent) VALUES (?, ?, ?, ?);', [$userrow['username'], $t, $c, $p]); db()->query('UPDATE forum SET newpostdate=CURRENT_TIMESTAMP, replies=replies + 1 WHERE id=?;', [$p]); redirect("forum.php?do=thread:$p:0"); } function newthread() { global $userrow; if (isset($_POST["submit"])) { extract($_POST); $t = trim($_POST['title'] ?? ''); $c = trim($_POST['content'] ?? ''); db()->query('INSERT INTO forum (author, title, content) VALUES (?, ?, ?);', [$userrow['username'], $t, $c]); redirect('forum.php'); } $page = "
Make A New Post:

Title:


Message:


"; display($page, "Forum"); }