the show starts kinda
This commit is contained in:
parent
b1936f4d3a
commit
037d15b650
5 changed files with 67 additions and 12 deletions
|
@ -22,6 +22,10 @@ body {
|
|||
margin-top: 0
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.banner {
|
||||
justify-content: center;
|
||||
margin-bottom: calc(-1*var(--elem-height))
|
||||
|
@ -49,17 +53,22 @@ body {
|
|||
|
||||
.banner,
|
||||
.banner-background,
|
||||
.content {
|
||||
.content,
|
||||
.comment {
|
||||
width: var(--elem-width)
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: var(--elem-width);
|
||||
justify-content: space-around;
|
||||
width: 300px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.banner pre {
|
||||
width: var(--elem-width);
|
||||
}
|
||||
|
||||
.avatar-img {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
|
@ -78,7 +87,8 @@ body {
|
|||
|
||||
.form-button,
|
||||
.form-input,
|
||||
.form {
|
||||
.form,
|
||||
.comment {
|
||||
border: solid var(--gray) 3px;
|
||||
background: var(--black);
|
||||
border-radius: var(--border-radius);
|
||||
|
|
|
@ -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();
|
||||
?>
|
||||
|
||||
<p>Very barren.</p>
|
||||
$form_message = post_handler();
|
||||
|
||||
<?php
|
||||
// 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);
|
||||
|
||||
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();
|
||||
?>
|
|
@ -2,7 +2,7 @@
|
|||
require("../libs/test_secret.php");
|
||||
|
||||
function auth($token) {
|
||||
if (is_null($token)) return '!guest';
|
||||
if (is_null($token)) return null;
|
||||
|
||||
global $db;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
$stmt->execute([$token]);
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$result) return '!guest';
|
||||
if (!$result) return null;
|
||||
|
||||
$username = $result['username'];
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
|||
$stmt->execute([$username]);
|
||||
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$result) return '!guest';
|
||||
if (!$result) return null;
|
||||
|
||||
return $username;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>NewBiglyChat</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -2,3 +2,4 @@ CREATE TABLE IF NOT EXISTS main.auth (username TEXT, password TEXT);
|
|||
CREATE TABLE IF NOT EXISTS main.token (username TEXT, token TEXT);
|
||||
CREATE TABLE IF NOT EXISTS main.user (username TEXT, bio TEXT);
|
||||
CREATE TABLE IF NOT EXISTS main.follow (username TEXT, target TEXT);
|
||||
CREATE TABLE IF NOT EXISTS main.comment (username TEXT, targetType TEXT, targetId TEXT, date REAL, content TEXT, id TEXT);
|
Loading…
Reference in a new issue