From 2b770fdab3d161736f481c650fffad5a9db866e1 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Mon, 2 Dec 2024 07:59:45 -0500 Subject: [PATCH] roles --- docs/index.php | 1 - docs/user.php | 18 ++++++++++++++---- libs/auth.php | 4 +++- scripts/init.sql | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/index.php b/docs/index.php index 53c0018..1d8db60 100644 --- a/docs/index.php +++ b/docs/index.php @@ -12,7 +12,6 @@ if (!$username) return; if (!array_key_exists('post',$_POST)) return; - $postie = $_POST['post']; if (strlen($postie) < 1 || strlen($postie) > 1024) { diff --git a/docs/user.php b/docs/user.php index 800eb1c..42a6eb7 100644 --- a/docs/user.php +++ b/docs/user.php @@ -1,6 +1,9 @@ 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 @@
@ + + [] +
diff --git a/libs/auth.php b/libs/auth.php index 1e05851..3689108 100644 --- a/libs/auth.php +++ b/libs/auth.php @@ -23,5 +23,7 @@ return $username; } - $username = auth($_COOKIE['token']); + if (array_key_exists('token',$_COOKIE)) { + $username = auth($_COOKIE['token']); + } ?> \ No newline at end of file diff --git a/scripts/init.sql b/scripts/init.sql index 28beebd..4a485d7 100644 --- a/scripts/init.sql +++ b/scripts/init.sql @@ -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); \ No newline at end of file