the show starts kinda
This commit is contained in:
parent
b1936f4d3a
commit
037d15b650
5 changed files with 67 additions and 12 deletions
|
@ -1,10 +1,53 @@
|
|||
<?php
|
||||
require("../libs/page.php");
|
||||
require("../libs/form.php");
|
||||
|
||||
$ref = 1732684297;
|
||||
|
||||
function post_handler() {
|
||||
global $ref;
|
||||
global $username;
|
||||
global $db;
|
||||
if (!$username) return;
|
||||
if (!array_key_exists('post',$_POST)) return;
|
||||
$postie = $_POST['post'];
|
||||
$stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)");
|
||||
$stmt->execute([$username,"root","root",microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]);
|
||||
}
|
||||
|
||||
page_header();
|
||||
?>
|
||||
|
||||
$form_message = post_handler();
|
||||
|
||||
// todo: make this not look weird
|
||||
if ($username) {
|
||||
form("Broadcast your thoughts...", $form_message, array(
|
||||
array('key' => 'Post', 'type' => 'textarea', 'name' => 'post', 'default' => '')
|
||||
));
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("SELECT * FROM comment ORDER BY date DESC");
|
||||
$stmt->execute([]);
|
||||
|
||||
$posts = $stmt->fetchAll(PDO::FETCH_DEFAULT);
|
||||
|
||||
<p>Very barren.</p>
|
||||
|
||||
<?php
|
||||
foreach ($posts as $post) { ?>
|
||||
<div class='comment'>
|
||||
<div class='avatar'>
|
||||
<img src='/pfp/<?php echo $post['username'] ?>.png' class='avatar-img'>
|
||||
<div>
|
||||
<div><b>
|
||||
<a class='link' href='/client/user?id=<?php echo $post['username'] ?>'>
|
||||
<?php echo $post['username'] ?>
|
||||
</a>
|
||||
</b></div>
|
||||
<div><b>
|
||||
<?php echo date(DATE_ATOM,$post['date'] + $ref) ?>
|
||||
</b></div>
|
||||
<pre><?php echo htmlspecialchars($post['content']) ?></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php }
|
||||
page_footer();
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue