Custom Blog
Description
Solution
<?php
session_start();
if (isset($_GET['post']) && file_exists($post = 'posts/' . $_GET['post'])) {
$ok = true;
} else {
$ok = false;
http_response_code(404);
}
...
if ($ok) {
echo '<h1>' . htmlentities($_GET['post']) . '</h1><hr><div class="post">';
include $post;
echo '</div>';
} else {
echo '<h1>post not found :(</h1><hr>';
}
...
?>


Last updated