Files
mallardnet/views/post.php
2025-11-22 23:57:26 -08:00

70 lines
2.8 KiB
PHP

<?php
$post = new Post($_SESSION["user"], $conn);
if (!$post->getSpecifcPost(htmlspecialchars($post_id)))
header("Location: /");
$post_details = $post->getSpecifcPost(htmlspecialchars($post_id));
?>
<html>
<head>
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
<link rel="stylesheet" href="/styles/main.css">
<script src="/scripts/from-now.js"></script>
</head>
<body>
<table class="container" align="center">
<tbody>
<?php require("includes/header.php"); ?>
<tr>
<?php require("includes/left_sidebar.php"); ?>
<td valign="top" align="left">
<table class="quack-container">
<tbody>
<tr>
<td>
<h2><?= $post_details['title']; ?></h2>
</td>
</tr>
<tr>
<td class="status-box">
by <h1><?= $post_details["author"]; ?> <img src="/images/badges/user.gif" alt="user"></h1>
<h2>- <span id="date-time"><?= $post_details["date"]; ?></span></h2>
<?php
if ($_SESSION["user"] == $post_details["author"])
echo "<a href=\"/delete_quack/".$post_details["id"]."\"><img alt=\"Delete\" src=\"/images/buttons/del.gif\" \></a>";
?>
</td>
</tr>
<tr>
<td class="quack-content">
<?= $post_details['content']; ?>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<?php require("includes/footer.php"); ?>
</tbody>
</table>
<script>
var alltimeStamps = document.querySelectorAll('#date-time');
// A little stack overflow-ish code?
for (var t=0;t<alltimeStamps.length; t++) {
const stringUTC = alltimeStamps[t].textContent.replace(' ', 'T') + 'Z';
const objUTC = new Date(stringUTC);
objUTC.setTime(objUTC.getTime() + objUTC.getTimezoneOffset()*60*1000);
console.log(alltimeStamps[t].textContent);
alltimeStamps[t].textContent = fromNow(objUTC);
}
</script>
</body>
</html>