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

@ -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>