This commit is contained in:
biglyderv 2024-12-02 07:59:45 -05:00
parent bf8e3ea138
commit 2b770fdab3
4 changed files with 18 additions and 6 deletions

View file

@ -12,7 +12,6 @@
if (!$username) return; if (!$username) return;
if (!array_key_exists('post',$_POST)) return; if (!array_key_exists('post',$_POST)) return;
$postie = $_POST['post']; $postie = $_POST['post'];
if (strlen($postie) < 1 || strlen($postie) > 1024) { if (strlen($postie) < 1 || strlen($postie) > 1024) {

View file

@ -1,6 +1,9 @@
<?php <?php
require("../libs/page.php"); require("../libs/page.php");
require("../libs/form.php"); require("../libs/form.php");
$roles = array();
page_header(); page_header();
// this is a mess // this is a mess
@ -11,6 +14,7 @@
global $bio; global $bio;
global $followers; global $followers;
global $following; global $following;
global $roles;
// there is 100% a better way to do this but i need to test // there is 100% a better way to do this but i need to test
if (!array_key_exists('id',$_GET)) { if (!array_key_exists('id',$_GET)) {
@ -19,9 +23,8 @@
$user = $_GET['id']; $user = $_GET['id'];
$type = $_GET['type'];
if (array_key_exists('type',$_GET)) { if (array_key_exists('type',$_GET)) {
$type = $_GET['type'];
if ($type == 'follow') { if ($type == 'follow') {
follow(); follow();
} else if ($type == 'settings') { } else if ($type == 'settings') {
@ -40,16 +43,20 @@
$bio = isset($result) ? $result['bio'] : 'This user has not set a bio.'; $bio = isset($result) ? $result['bio'] : 'This user has not set a bio.';
$stmt = $db->prepare("SELECT * FROM follow WHERE target = ?"); $stmt = $db->prepare("SELECT * FROM main.follow WHERE target = ?");
$stmt->execute([$user]); $stmt->execute([$user]);
$following = $stmt->fetchAll(PDO::FETCH_DEFAULT); $following = $stmt->fetchAll(PDO::FETCH_DEFAULT);
$stmt = $db->prepare("SELECT * FROM follow WHERE username = ?"); $stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ?");
$stmt->execute([$user]); $stmt->execute([$user]);
$followers = $stmt->fetchAll(PDO::FETCH_DEFAULT); $followers = $stmt->fetchAll(PDO::FETCH_DEFAULT);
$stmt = $db->prepare("SELECT * FROM main.role WHERE username = ?");
$stmt->execute([$user]);
$roles = $stmt->fetchAll(PDO::FETCH_DEFAULT);
} }
function follow() { function follow() {
@ -97,6 +104,9 @@
<div class="avatar"> <div class="avatar">
<img src="/pfp/<?php echo $user ?>.png" class="avatar-img"> <img src="/pfp/<?php echo $user ?>.png" class="avatar-img">
<b>@<?php echo $user ?></b> <b>@<?php echo $user ?></b>
<?php foreach ($roles as $role) { ?>
[<?php echo htmlspecialchars($role['role']); ?>]
<?php } ?>
<input class="form-button" type="submit" value="Follow"> <input class="form-button" type="submit" value="Follow">
</div> </div>

View file

@ -23,5 +23,7 @@
return $username; return $username;
} }
$username = auth($_COOKIE['token']); if (array_key_exists('token',$_COOKIE)) {
$username = auth($_COOKIE['token']);
}
?> ?>

View file

@ -1,5 +1,6 @@
CREATE TABLE IF NOT EXISTS main.auth (username TEXT, password TEXT); 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.token (username TEXT, token TEXT);
CREATE TABLE IF NOT EXISTS main.user (username TEXT, bio TEXT); CREATE TABLE IF NOT EXISTS main.user (username TEXT, bio TEXT);
CREATE TABLE IF NOT EXISTS main.role (username TEXT, role TEXT);
CREATE TABLE IF NOT EXISTS main.follow (username TEXT, target 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); CREATE TABLE IF NOT EXISTS main.comment (username TEXT, targetType TEXT, targetId TEXT, date REAL, content TEXT, id TEXT);