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 (!array_key_exists('post',$_POST)) return;
$postie = $_POST['post'];
if (strlen($postie) < 1 || strlen($postie) > 1024) {

View file

@ -1,6 +1,9 @@
<?php
require("../libs/page.php");
require("../libs/form.php");
$roles = array();
page_header();
// this is a mess
@ -11,6 +14,7 @@
global $bio;
global $followers;
global $following;
global $roles;
// there is 100% a better way to do this but i need to test
if (!array_key_exists('id',$_GET)) {
@ -18,10 +22,9 @@
}
$user = $_GET['id'];
$type = $_GET['type'];
if (array_key_exists('type',$_GET)) {
$type = $_GET['type'];
if ($type == 'follow') {
follow();
} else if ($type == 'settings') {
@ -40,16 +43,20 @@
$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]);
$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]);
$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() {
@ -97,6 +104,9 @@
<div class="avatar">
<img src="/pfp/<?php echo $user ?>.png" class="avatar-img">
<b>@<?php echo $user ?></b>
<?php foreach ($roles as $role) { ?>
[<?php echo htmlspecialchars($role['role']); ?>]
<?php } ?>
<input class="form-button" type="submit" value="Follow">
</div>

View file

@ -23,5 +23,7 @@
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.token (username TEXT, token 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.comment (username TEXT, targetType TEXT, targetId TEXT, date REAL, content TEXT, id TEXT);