minor fixes

This commit is contained in:
biglyderv 2025-02-05 01:27:45 -05:00
parent daace699a6
commit 2ce4424db7
20 changed files with 674 additions and 621 deletions

View file

@ -1,9 +1,11 @@
<?php
require(__DIR__ . "/../../libs/page.php");
$ref = 1732684297;
function getOut($typer, $idr) {
function getOut($typer, $idr)
{
if ($typer == 'user' || $typer == 'comment') {
header("Location: " . '/' . $typer . '.php?id=' . htmlspecialchars($idr));
die();
@ -13,11 +15,14 @@
die();
}
function post_handler() {
function post_handler()
{
global $ref;
global $username;
global $db;
if (!$username || !array_key_exists('post',$_POST)) return;
if (!$username || !array_key_exists('post', $_POST)) {
return;
}
$postie = $_POST['post'];
$postType = (array_key_exists('type', $_POST)) ? $_POST['type'] : 'root';
@ -85,4 +90,3 @@
}
post_handler();
?>

View file

@ -1,7 +1,9 @@
<?php
require(__DIR__ . "/../../libs/page.php");
function get_handler() {
function get_handler()
{
global $db;
$stmt = $db->prepare("SELECT * FROM main.follow");
@ -13,4 +15,3 @@
}
get_handler();
?>

View file

@ -1,4 +1,5 @@
<?php
require(__DIR__ . "/../libs/page.php");
require(__DIR__ . "/../libs/form.php");
require(__DIR__ . "/../libs/comment.php");
@ -8,4 +9,3 @@
page_header();
comments("comment", $_GET['id']);
page_footer();
?>

View file

@ -134,6 +134,7 @@ pre {
padding: 10px;
margin-bottom: 10px;
align-items: center;
flex-wrap: wrap;
width: var(--elem-width);
border-radius: var(--border-radius);
}
@ -186,6 +187,10 @@ iframe {
border: none;
}
.header a {
width: 60px;
}
.header a, .clickie {
text-decoration: none;
color: inherit;

View file

@ -17,8 +17,6 @@
<h2>Community</h2>
<a class="form-button" href="/tou.php">Terms of Use</a>
<a class="form-button" href="/stats.php?ref=<?php echo $username ?>">Suggested Users</a>
<a class="form-button" href="/stats.php">Top Users</a>
<a class="form-button" href="https://dervland.net/">More Projects</a>
</div>
</div>

View file

@ -1,8 +1,10 @@
<?php
require(__DIR__ . "/../libs/page.php");
require(__DIR__ . "/../libs/form.php");
function post_handler() {
function post_handler()
{
global $db;
// there is 100% a better way to do this but i need to test
@ -18,11 +20,15 @@
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$result) return 'Username does not exist.';
if (!$result) {
return 'Username does not exist.';
}
$verified = password_verify($pass, $result['password']);
if (!$verified) return 'Password is wrong.';
if (!$verified) {
return 'Password is wrong.';
}
$token = bin2hex(random_bytes(32));
@ -52,4 +58,3 @@
));
page_footer();
?>

View file

@ -1,13 +1,12 @@
<?php
require(__DIR__ . "/../libs/page.php");
page_header();
if (isset($_COOKIE)) {
foreach ( $_COOKIE as $key => $value )
{
setcookie( $key, FALSE );
foreach ($_COOKIE as $key => $value) {
setcookie($key, false);
}
header("Location: /");
die();
}
page_footer();
?>

View file

@ -8,7 +8,8 @@
page_header();
// this is a mess
function get_handler() {
function get_handler()
{
global $db;
global $username;
global $user;
@ -55,7 +56,8 @@
<h2>Following</h2>
<?php
foreach ($following as $user) { $usern = $user['username']; ?>
foreach ($following as $user) {
$usern = $user['username']; ?>
<div class='comment'>
<div class="avatar">
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">
@ -76,7 +78,8 @@
<h2>Followers</h2>
<?php
foreach ($followers as $user) { $usern = $user['target']; ?>
foreach ($followers as $user) {
$usern = $user['target']; ?>
<div class='comment'>
<div class="avatar">
<img src="/pfp/<?php echo $usern ?>.png" class="avatar-img">

View file

@ -1,4 +1,5 @@
<?php
require(__DIR__ . "/../libs/page.php");
require(__DIR__ . "/../libs/form.php");
require(__DIR__ . "/../libs/comment.php");
@ -8,4 +9,3 @@
page_header();
comments("notification", $username, true);
page_footer();
?>

View file

@ -1,8 +1,10 @@
<?php
require(__DIR__ . "/../libs/page.php");
require(__DIR__ . "/../libs/form.php");
function post_handler() {
function post_handler()
{
global $db;
// there is 100% a better way to do this but i need to test
@ -33,7 +35,9 @@
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if ($result) return 'Username is taken.';
if ($result) {
return 'Username is taken.';
}
$hashed = password_hash($pass, PASSWORD_DEFAULT);
@ -55,4 +59,3 @@
));
page_footer();
?>

View file

@ -3,7 +3,8 @@
require(__DIR__ . "/../libs/form.php");
require(__DIR__ . "/../libs/comment.php");
function cmp($a, $b) {
function cmp($a, $b)
{
if ($a == $b) {
return 0;
}
@ -11,8 +12,17 @@
}
page_header();
?>
function get_handler() {
<div>
<a class="form-button" href="?username=<?php echo $username ?>">Local</a>
<a class="form-button" href="?">Global</a>
</div>
<?php
function get_handler()
{
$api = file_get_contents("https://nbg.dervland.net/node/top?ref=" . $_GET['ref']);
$pr = json_decode($api);

View file

@ -8,7 +8,8 @@
page_header();
// this is a mess
function get_handler() {
function get_handler()
{
global $db;
global $username;
global $user;
@ -56,7 +57,8 @@
$roles = $stmt->fetchAll(PDO::FETCH_DEFAULT);
}
function follow() {
function follow()
{
global $db;
global $username;
global $user;
@ -66,7 +68,9 @@
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (is_null($username)) return;
if (is_null($username)) {
return;
}
if ($result) {
$stmt = $db->prepare("DELETE FROM main.follow WHERE username = ? AND target = ?");
@ -76,12 +80,15 @@
$stmt->execute([$user,$username]);
}
}
function settings() {
function settings()
{
global $db;
global $username;
global $user;
if (is_null($username)) return;
if (is_null($username)) {
return;
}
$stmt = $db->prepare("DELETE FROM main.user WHERE username = ?");
$stmt->execute([$username]);

View file

@ -1,8 +1,11 @@
<?php
require(__DIR__ . "/test_secret.php");
function auth($token) {
if (is_null($token)) return null;
function auth($token)
{
if (is_null($token)) {
return null;
}
global $db;
@ -10,7 +13,9 @@
$stmt->execute([$token]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$result) return null;
if (!$result) {
return null;
}
$username = $result['username'];
@ -18,13 +23,17 @@
$stmt->execute([$username]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$result) return null;
if (!$result) {
return null;
}
$stmt = $db->prepare("SELECT * FROM main.ban WHERE username = ?");
$stmt->execute([$username]);
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$result) return $username;
if (!$result) {
return $username;
}
$reason = $result['reason']; ?>
<!DOCTYPE html>

View file

@ -1,6 +1,7 @@
<?php
require(__DIR__ . "/markdown.php");
function comments($typer, $idr, $disable = false) {
function comments($typer, $idr, $disable = false)
{
$ref = 1732684297;
global $username;
global $db;
@ -17,7 +18,9 @@
$qs = parse_url($_SERVER['REQUEST_URI']);
if (is_null($qs)) $qs = array('query' => '?');
if (is_null($qs)) {
$qs = array('query' => '?');
}
$qsq = $qs['query'];
$qss = array();
@ -37,6 +40,10 @@
$qs_2 = http_build_query($qss);
?>
<div>
<a class="form-button" href="?<?php echo $qs_1 ?>">Everyone</a>
<a class="form-button" href="?<?php echo $qs_2 ?>">Following</a>
</div>
<div>
<?php if ($page > 0) { ?>
<a class="form-button" href="?<?php echo $qs_prev ?>">Previous</a>
@ -44,10 +51,6 @@
<a class="form-button" href="?<?php echo $qs_next ?>">Next</a>
</div>
<div>
<a class="form-button" href="?<?php echo $qs_1 ?>">Everyone</a>
<a class="form-button" href="?<?php echo $qs_2 ?>">Following</a>
</div>
<?php
$posts = array();
@ -60,7 +63,9 @@
$theId
]);
$posts1 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
if (is_null($posts1) || count($posts1) < 1) break;
if (is_null($posts1) || count($posts1) < 1) {
break;
}
$theId = $posts1[0]['targetid'];
$posts = array_merge($posts1, $posts);
}

View file

@ -1,5 +1,6 @@
<?php
function form($title, $form_message, $inputs, $action = '') { ?>
function form($title, $form_message, $inputs, $action = '')
{ ?>
<form class='form' enctype="multipart/form-data" method="POST" action="<?php echo $action ?>">
<h1 class="form-heading">
<?php echo $title ?>

View file

@ -1,5 +1,6 @@
<?php
function markdown($text) {
function markdown($text)
{
$search = array(
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(png|jpg|jpeg|gif))~i',
'~(https://[^.]+\.dervland\.net/[^\s<]+\.(mp3|wav))~i',

View file

@ -1,7 +1,8 @@
<?php
require(__DIR__ . "/auth.php");
global $username;
function page_header() {
function page_header()
{
global $db;
global $username;
$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date DESC");
@ -11,7 +12,6 @@
]);
$posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT);
$edge = count($posts2);
?>
<!DOCTYPE html>
@ -25,18 +25,20 @@
<body>
<div class="header">
<a href="/"><img class="header-img header-link" src="/img/bgc.svg">BiglyChat</a>
<?php
if (isset($username)) { ?>
<a href="/user.php?id=<?php echo $username ?>"><img class="header-img header-link" src="/img/home.svg">Home</a>
<?php if (isset($username)) { ?>
<a href="/user.php?id=<?php echo $username ?>"><img class="header-img header-link" src="/pfp/<?php echo $username ?>.png">Wall</a>
<a href="/notif.php"> <img class="header-img header-link" src="/img/mail.svg"><span>Mail<sub> <?php echo $edge?></sub></span></a>
<a href="/stats.php?username=<?php echo $username ?>"><img class="header-img header-link" src="/img/home.svg">Users</a>
<a href="/logout.php"><img class="header-img header-link" src="/img/logout.svg">Leave</a>
<?php } else { ?>
<a href="/login.php"><img class="header-img header-link" src="/img/home.svg">Join</a>
<a href="/stats.php"><img class="header-img header-link" src="/img/home.svg">Users</a>
<?php }
?>
</div>
<?php }
function page_footer() { ?>
function page_footer()
{ ?>
</body>
</html>
<?php }

View file

@ -1,4 +1,5 @@
<?php
require(__DIR__ . "/../libs/test_secret.php");
global $db;
@ -8,4 +9,3 @@
$db->exec($sql);
echo "Database was set up.";
?>