get('/blog.php', function() { header('Location: /old-blog/' . (int)filter_input(INPUT_GET, 'p', FILTER_SANITIZE_NUMBER_INT)); return 302; }); $router->get('/blog-post.php', function() { header('Location: /old-blog/' . (int)filter_input(INPUT_GET, 'p', FILTER_SANITIZE_NUMBER_INT)); return 302; }); $router->get('/blog/:id', function(string $id) { header('Location: /old-blog/' . intval($id)); return 302; }); $router->get('/old-blog', function() { $blogInfo = json_decode(file_get_contents(MKI_DIR_PUB . '/old_blog_posts.json')); $body = fm_component('header', [ 'title' => 'flash.moe / old blog posts', ]); $body .= <<
List of old blog posts to enjoy while I Eventually make the new script.
HTML; $body .= '
'; foreach($blogInfo as $postInfo) { $preview = trim(explode("\n", $postInfo->post_text)[0]); $dateCustom = date('Y-m-d @ H:i:s T', $postInfo->post_published); $dateISO = date('c', $postInfo->post_published); $body .= <<

{$postInfo->post_title}

{$preview}

Continue reading
\r\n HTML; } $body .= '
'; $body .= fm_component('footer'); return $body; }); $router->get('/old-blog/:id', function(string $id) { if(!is_numeric($id)) return 404; $postId = intval($id); $blogInfo = json_decode(file_get_contents(MKI_DIR_PUB . '/old_blog_posts.json')); foreach($blogInfo as $postInfo) { if($postInfo->post_id !== $postId) continue; $dateCustom = date('Y-m-d @ H:i:s T', $postInfo->post_published); $dateISO = date('c', $postInfo->post_published); $preview = trim(explode("\n", $postInfo->post_text)[0]); $body = fm_component('header', [ 'title' => 'flash.moe / ' . $postInfo->post_title, ]); $body .= '
'; if(!empty($postInfo->post_new_url)) $body .= "post_new_url}\" style=\"display: block; text-align: center; color: #fff; text-decoration: none; font-size: 2em; line-height: 1.5em; padding: 20px 10px; margin: 10px 0; font-weight: bold; background-color: #222; border-radius: 5px\">This post has a new url, please go here instead!"; $body .= "

{$postInfo->post_title}

"; $body .= ""; $splitLines = explode("\n", $postInfo->post_text); foreach ($splitLines as $paragraph) if(!empty($paragraph)) $body .= '

' . trim($paragraph) . '

'; $body .= '
'; $body .= fm_component('footer'); return $body; } return 404; });