From 08fe66906c8635724ae9a05d34e5ffbdb97ced0f Mon Sep 17 00:00:00 2001 From: biglyderv Date: Sun, 23 Feb 2025 01:52:53 -0500 Subject: [PATCH 1/2] some fixes --- docs/index.php | 12 ++------ libs/comment.php | 11 ------- libs/page.php | 75 ++++++++++++++++++++++++------------------------ 3 files changed, 40 insertions(+), 58 deletions(-) diff --git a/docs/index.php b/docs/index.php index 5c7caff..1ea5085 100644 --- a/docs/index.php +++ b/docs/index.php @@ -4,25 +4,17 @@ require(__DIR__ . "/../libs/form.php"); require(__DIR__ . "/../libs/comment.php"); page_header(); -if (!is_null($username)) { - //comments("root","root"); -} if (!($_GET['page'] > 0) && is_null($username)) { ?> diff --git a/libs/comment.php b/libs/comment.php index f3fb034..63ddbd4 100644 --- a/libs/comment.php +++ b/libs/comment.php @@ -32,18 +32,7 @@ function comments($typer, $idr, $disable = false) $qss['page'] = $page - 1; $qs_prev = http_build_query($qss); $qss['page'] = $page; - - $qss['mode'] = 'all'; - $qs_1 = http_build_query($qss); - - $qss['mode'] = 'followers'; - $qs_2 = http_build_query($qss); ?> - -
- Everyone - Following -
0) { ?> Previous diff --git a/libs/page.php b/libs/page.php index c250979..da182a2 100755 --- a/libs/page.php +++ b/libs/page.php @@ -14,50 +14,51 @@ function page_header() $posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT); $edge = count($posts2); ?> - - - - BiglyChat - - - - - -
- BiglyChat - - Wall - Mail - Users - Leave - - Join - Users - -
- + + + BiglyChat + + + + + +
+ BiglyChat + + Feed + Wall + Users + Mail + Leave + + Join + Users + +
+ +{ +?> - -
-
+
+
-
- - - - + + + + +
-
-
- $tag: $meta"; ?> -
- + $tag: $meta"; ?> +
+ From f44c90647f35362bcf38dc7f137e8867b67731c7 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Sat, 3 May 2025 13:39:43 -0400 Subject: [PATCH 2/2] reading messages --- docs/notif.php | 10 ++++++++++ libs/page.php | 10 +++++++++- scripts/init.php | 2 +- scripts/init.sql | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/notif.php b/docs/notif.php index e96fee3..0e8a2cc 100644 --- a/docs/notif.php +++ b/docs/notif.php @@ -6,6 +6,16 @@ require(__DIR__ . "/../libs/comment.php"); $ref = 1732684297; +$stmt = $db->prepare("DELETE FROM main.read WHERE username = ?"); +$stmt->execute([$username]); + +$stmt = $db->prepare("SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date"); +$stmt->execute(["notification",$username]); +$counter = $stmt->fetchAll(PDO::FETCH_DEFAULT); + +$stmt = $db->prepare("INSERT INTO main.read (username, msgs) VALUES (?, ?)"); +$stmt->execute([$username, count($counter)]); + page_header(); comments("notification", $username, true); page_footer(); diff --git a/libs/page.php b/libs/page.php index da182a2..40d74d8 100755 --- a/libs/page.php +++ b/libs/page.php @@ -12,7 +12,15 @@ function page_header() ]); $posts2 = $stmt->fetchAll(PDO::FETCH_DEFAULT); - $edge = count($posts2); + + $stmt = $db->prepare("SELECT * FROM main.read WHERE username = ?"); + $stmt->execute([ + $username + ]); + + $counter = $stmt->fetchAll(PDO::FETCH_DEFAULT); + + $edge = count($posts2) - $counter[0]['msgs']; ?> diff --git a/scripts/init.php b/scripts/init.php index 7d27613..855440a 100755 --- a/scripts/init.php +++ b/scripts/init.php @@ -4,7 +4,7 @@ require(__DIR__ . "/../libs/test_secret.php"); global $db; -$sql = file_get_contents('../scripts/init.sql', true); +$sql = file_get_contents(__DIR__ .'/../scripts/init.sql', true); $db->exec($sql); diff --git a/scripts/init.sql b/scripts/init.sql index ad101b5..c3885bd 100755 --- a/scripts/init.sql +++ b/scripts/init.sql @@ -4,4 +4,5 @@ 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.ban (username TEXT, reason TEXT); +CREATE TABLE IF NOT EXISTS main.read (username TEXT, msgs REAL); CREATE TABLE IF NOT EXISTS main.comment (username TEXT, targetType TEXT, targetId TEXT, date REAL, content TEXT, id TEXT);