new-bigly-chat/docs/index.php
2024-11-30 04:48:58 -05:00

71 lines
No EOL
2.4 KiB
PHP

<?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();
if ($username) {
form("Broadcast your thoughts...", $form_message, array(
array('key' => 'Your message', 'type' => 'textarea', 'name' => 'post', 'default' => '')
));
}
$stmt = $db->prepare("SELECT * FROM comment ORDER BY date DESC");
$stmt->execute([]);
$posts = $stmt->fetchAll(PDO::FETCH_DEFAULT);
?>
<div class="banner"><img class="banner-background" src="/img/newlogo.svg">
<div class="banner-content">
<h1>BiglyChat</h1>
<p>BiglyChat is a niche community for broadcasting videos, playing games, and chatting with friends.</p>
<h2>Community</h2>
<a class="form-button" href="/register.php">Join the Community</a>
<br>
<a class="form-button" href="/tou.php">Terms of Use</a>
<a class="form-button" href="https://dervland.net/">More Projects</a>
<a class="form-button" href="https://git.dervland.net/biglyderv/new-bigly-chat">Developer Portal</a>
</div>
</div>
<?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='/user.php?id=<?php echo $post['username'] ?>'>
<?php echo $post['username'] ?>
</a>
</b></div>
<div><b>
<?php echo date(DATE_ATOM,$post['date'] + $ref) ?>
</b></div>
</div>
</div>
<pre><?php echo htmlspecialchars($post['content']) ?></pre>
</div>
<?php }
page_footer();
?>