new-bigly-chat/docs/index.php

65 lines
2.1 KiB
PHP
Raw Normal View History

2024-11-26 11:38:28 -05:00
<?php
require("../libs/page.php");
2024-11-27 00:13:33 -05:00
require("../libs/form.php");
2024-12-06 08:26:03 -05:00
require("../libs/comment.php");
2024-11-27 00:13:33 -05:00
$ref = 1732684297;
2024-12-06 08:26:03 -05:00
function getOut($typer, $idr) {
2024-12-11 23:51:42 -05:00
if ($typer == 'user' || $typer == 'comment') {
header("Location: " . '/' . $typer . '.php?id=' . htmlspecialchars($idr));
2024-12-06 08:26:03 -05:00
die();
}
header("Location: " . $_SERVER["REQUEST_URI"]);
die();
}
2024-11-27 00:13:33 -05:00
function post_handler() {
global $ref;
global $username;
global $db;
2024-12-06 10:19:57 -05:00
if (!$username || !array_key_exists('post',$_POST)) return;
2024-11-30 17:20:46 -05:00
2024-11-27 00:13:33 -05:00
$postie = $_POST['post'];
2024-12-06 08:26:03 -05:00
$postType = (array_key_exists('type',$_POST)) ? $_POST['type'] : 'root';
$postId = (array_key_exists('id',$_POST)) ? $_POST['id'] : 'root';
2024-11-30 17:20:46 -05:00
if (strlen($postie) < 1 || strlen($postie) > 1024) {
2024-12-06 08:26:03 -05:00
getOut($postType,$postId);
}
2024-12-07 17:51:05 -05:00
if (is_uploaded_file($_FILES['file']['tmp_name'])) {
$fid = bin2hex(random_bytes(16));
move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . '/../docs/pic/' . $fid . '.png');
$postie .= "\nhttps://" . $_SERVER['HTTP_HOST'] . '/pic/' . $fid . '.png';
}
2024-11-27 00:13:33 -05:00
$stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)");
2024-12-06 08:26:03 -05:00
$stmt->execute([$username,$postType,$postId,microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]);
2024-12-07 17:51:05 -05:00
2024-12-06 08:26:03 -05:00
getOut($postType,$postId);
}
post_handler();
2024-11-26 11:38:28 -05:00
2024-11-27 00:13:33 -05:00
page_header();
2024-11-30 04:48:58 -05:00
?>
<div class="banner"><img class="banner-background" src="/img/newlogo.svg">
<div class="banner-content">
<h1>BiglyChat</h1>
2024-11-30 04:52:01 -05:00
<pre>BiglyChat is a niche community for weird Dervland experiments and games.</pre>
2024-11-30 04:48:58 -05:00
<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>
2024-12-06 08:26:03 -05:00
<?php
comments("root","root");
page_footer();
2024-12-02 23:02:11 -05:00
?>