flash.moe/public/2020/blog.php

85 lines
2.7 KiB
PHP
Raw Normal View History

2020-08-20 00:02:37 +00:00
<?php
require_once __DIR__ . '/../_v4/includes.php';
define('FWH_STYLE', FWH_2020);
$blogMode = !empty($_GET['blog']);
$postId = !empty($_GET['p']) && is_string($_GET['p']) && ctype_digit($_GET['p']) ? (int)($_GET['p']) : 0;
if($postId < 1) {
header('Location: /2020');
exit;
}
$getPost = $pdo->prepare('
SELECT `post_id`, `post_title`, `post_text`, UNIX_TIMESTAMP(`post_published`) AS `post_published`, `post_safe`, `post_new_url`
FROM `fm_blog_posts`
WHERE `post_id` = :id
AND `post_published` IS NOT NULL
AND `post_published` < CURRENT_TIMESTAMP
AND `post_deleted` IS NULL
');
$getPost->bindValue('id', $postId);
$post = $getPost->execute() ? $getPost->fetch(PDO::FETCH_OBJ) : false;
if(html_default_mode() === FWH_JVDG && empty($post->post_safe))
unset($post);
if(!empty($post)) {
$dateCustom = date('Y-m-d @ H:i:s T', $post->post_published);
$dateISO = date('c', $post->post_published);
$preview = trim(explode("\n", $post->post_text)[0]);
$title = $post->post_title;
} else http_response_code(404);
if($blogMode) {
fm_component('header', [
'title' => $title,
'styles' => [
'/css/2020.css'
],
]);
} else {
2020-08-20 00:02:37 +00:00
echo html_doctype();
?>
<html lang="en">
<head>
<?=html_charset();?>
<title><?=$title ?? 'flash.moe';?></title>
<?=html_stylesheet('2020.css');?>
<?=html_meta();?>
</head>
<body>
<?php } ?>
2020-08-20 00:02:37 +00:00
<div class="wrapper">
<?php if(!$blogMode) echo html_sidebar(); ?>
<?php if(empty($post)) { ?>
<div class="notfound">
<h1>Post not found!</h1>
<p>You either went to an invalid URL or this post has been deleted.</p>
</div>
<?php } else { ?>
<div class="blog">
<?php if(!empty($post->post_new_url)): ?>
<a href="<?=$post->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">This post has a new url, please go here instead!</a>
<?php endif; ?>
<h1><?=$post->post_title;?></h1>
<time datetime="<?=$dateISO;?>"><?=$dateCustom;?></time>
<?php
$splitLines = explode("\n", $post->post_text);
foreach ($splitLines as $paragraph)
if(!empty($paragraph))
echo '<p>' . trim($paragraph) . '</p>';
?>
</div>
<?php } ?>
</div>
<?php if($blogMode): fm_component('footer'); else: ?>
2020-08-20 00:02:37 +00:00
<?php if(html_old_ie()) { ?>
<?=html_script('/assets/fixpng.js');?>
<?php } ?>
</body>
</html>
<?php endif; ?>