/** * Caches this forum post - we don't want to parse BBCodes each time * we want to display a forum post. * * @return void */ public function cache() { $bbcode = new BBCode(); $rendered = $bbcode->render($this->text); $rendered = emojis($rendered); Cache::put(self::CACHE_KEY . $this->id, $rendered, 60); }
echo "<div id='nav'>"; if ($_SESSION['id'] == 1) { echo "<a href='admin/' id='nava'>Admin</a>"; } echo <<<END \t\t\t<a href='?logout' id='nava'>Logout</a> \t\t</div> END; $posts = mysqli_query($connection, "SELECT * FROM posts ORDER BY date DESC"); $num = 10; if (mysqli_num_rows($posts) < 10) { $num = mysqli_num_rows($posts); } for ($i = 0; $i < $num; $i++) { $post = mysqli_fetch_row($posts); echo "<div id='post'>"; if ($_SESSION['id'] == 1) { echo "<a href='admin/?delete=" . $post[0] . "' id='delete'></a> <a href='admin/?edit=" . $post[0] . "' id='edit'></a>"; } echo "<h2>" . emojis($post[1]) . "</h2><i id='date'>" . date("M jS Y g:ia", $post[3]) . "</i><pre>" . emojis(Parsedown::instance()->text($post[2])) . "</pre></div>"; } if (!$num) { echo "There is no messages yet."; } } } echo <<<END \t</body> </html> END; mysqli_close($connection);