59 lines
1.8 KiB
PHP
Executable file
59 lines
1.8 KiB
PHP
Executable file
<?php
|
|
require("../libs/page.php");
|
|
require("../libs/form.php");
|
|
require("../libs/comment.php");
|
|
|
|
$ref = 1732684297;
|
|
|
|
function getOut($typer, $idr) {
|
|
if ($typer == 'user') {
|
|
header("Location: " . '/user.php?id=' . htmlspecialchars($idr));
|
|
die();
|
|
}
|
|
|
|
header("Location: " . $_SERVER["REQUEST_URI"]);
|
|
die();
|
|
}
|
|
|
|
function post_handler() {
|
|
global $ref;
|
|
global $username;
|
|
global $db;
|
|
if (!$username) getOut('root','root');
|
|
if (!array_key_exists('post',$_POST)) return;
|
|
|
|
$postie = $_POST['post'];
|
|
$postType = (array_key_exists('type',$_POST)) ? $_POST['type'] : 'root';
|
|
$postId = (array_key_exists('id',$_POST)) ? $_POST['id'] : 'root';
|
|
|
|
if (strlen($postie) < 1 || strlen($postie) > 1024) {
|
|
getOut($postType,$postId);
|
|
}
|
|
|
|
$stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)");
|
|
$stmt->execute([$username,$postType,$postId,microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]);
|
|
|
|
getOut($postType,$postId);
|
|
}
|
|
|
|
post_handler();
|
|
|
|
page_header();
|
|
?>
|
|
|
|
<div class="banner"><img class="banner-background" src="/img/newlogo.svg">
|
|
<div class="banner-content">
|
|
<h1>BiglyChat</h1>
|
|
<pre>BiglyChat is a niche community for weird Dervland experiments and games.</pre>
|
|
<h2>Community</h2>
|
|
|
|
<a class="form-button" href="/register.php">Join the Community</a>
|
|
<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
|
|
comments("root","root");
|
|
page_footer();
|
|
?>
|