2020-03-08 16:15:23 +01:00
|
|
|
<?php
|
2021-09-02 17:01:28 +02:00
|
|
|
$pdo = new PDO('mysql:host=%DB_SERVER%;dbname=%DB_NAME%', '%DB_USERNAME%', '%DB_PASSWORD%');
|
2020-03-12 23:03:13 +01:00
|
|
|
$statement = $pdo->prepare("SELECT * FROM posts WHERE board_id=:bid ORDER BY post_time asc");
|
|
|
|
$statement->execute(array("bid"=>$id));
|
|
|
|
foreach($statement->fetchAll() as $ROW) {
|
2021-09-05 08:39:32 +02:00
|
|
|
|
|
|
|
// get post creator
|
2020-03-12 23:03:13 +01:00
|
|
|
$statement = $pdo->prepare("SELECT * FROM users WHERE id=:uid");
|
|
|
|
$statement->execute(array("uid"=>$ROW[user_id]));
|
2020-03-12 23:14:03 +01:00
|
|
|
$post_creator = $statement->fetch();
|
|
|
|
|
2021-09-05 08:39:32 +02:00
|
|
|
// get post content and make sure it doesn't mess with the website
|
2021-09-07 07:07:00 +02:00
|
|
|
$post_id = $ROW['id'];
|
|
|
|
$post_title = htmlspecialchars($ROW['title']);
|
2020-03-12 23:14:03 +01:00
|
|
|
$post_creator_name = htmlspecialchars($post_creator['name']);
|
2021-09-07 07:07:00 +02:00
|
|
|
$post_time = htmlspecialchars($ROW['post_time']);
|
|
|
|
$post_content = htmlspecialchars($ROW['content']);
|
2020-03-12 23:14:03 +01:00
|
|
|
|
2021-09-02 05:09:32 +02:00
|
|
|
// add line breaks to post content, to be replaced with proper makrdown support in the future (see #44)
|
2021-09-02 05:11:58 +02:00
|
|
|
$newlines = array("\r\n", "\n\r", "\r", "\n"); // two-character newlines first to prevent placing two line breaks instead of one
|
2021-09-02 05:55:43 +02:00
|
|
|
$post_content = str_replace($newlines, "<br />", $post_content);
|
2021-09-02 05:09:32 +02:00
|
|
|
|
2021-09-07 07:53:22 +02:00
|
|
|
// if this is a reply, build reference
|
2021-09-05 08:39:32 +02:00
|
|
|
$reply_to = $ROW['reply_to'];
|
2021-09-07 07:53:22 +02:00
|
|
|
if ($reply_to > -1) {
|
2021-09-07 07:59:04 +02:00
|
|
|
$reply_reference = "<p class=\"post_reply\" >This is a reply to <a href=./?id=" . $_GET['id'] . "#$reply_to >this</a> message.</p>";
|
2021-09-07 07:53:22 +02:00
|
|
|
} else {
|
2021-09-07 07:54:50 +02:00
|
|
|
$reply_reference = "";
|
2021-09-07 07:53:22 +02:00
|
|
|
}
|
2021-09-05 08:39:32 +02:00
|
|
|
|
2021-09-07 07:07:00 +02:00
|
|
|
echo "<section id=\"$post_id\" >
|
2021-09-07 08:39:26 +02:00
|
|
|
<div>
|
2021-09-07 08:47:31 +02:00
|
|
|
<a href=\"./?id=" . $_GET['id'] . "&action=post&reply_to=$post_id&end\" class=\"post_reply\">
|
2021-09-07 08:39:26 +02:00
|
|
|
<button class=\"post_reply\">Reply</button>
|
|
|
|
</a>
|
|
|
|
<h1 class=\"post\">$post_title</h1>
|
|
|
|
$reply_reference
|
|
|
|
</div>
|
|
|
|
<article>
|
|
|
|
<header>
|
|
|
|
<div>
|
|
|
|
<p class='beige'> $post_creator_name <time datetime='$post_time'>$post_time</time></p>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<div class='postcontent'>
|
|
|
|
<p>$post_content</p>
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</section>";
|
2020-03-08 15:03:30 +01:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
|