diff --git a/docs/index.php b/docs/index.php index fdac724..2d6073f 100755 --- a/docs/index.php +++ b/docs/index.php @@ -45,9 +45,31 @@ } } + $poid = bin2hex(random_bytes(16)); $stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)"); - $stmt->execute([$username,$postType,$postId,microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]); + $stmt->execute([$username,$postType,$postId,microtime(true) - $ref,$postie,$poid]); + + $postieP = "https://nbg.dervland.net/comment.php?id=" . $poid; + + $user10 = '%system'; + if ($postType == 'user') { + $postie = "A user commented on your wall: " . $postieP; + $stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)"); + $stmt->execute([$user10,'notification',$postId,microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]); + } else if ($postType == 'comment') { + $stmt = $db->prepare("SELECT * FROM comment WHERE id = ? ORDER BY date DESC"); + $stmt->execute([ + $poid + ]); + $posts1 = $stmt->fetchAll(PDO::FETCH_DEFAULT); + + $posts2 = $posts1[0]['username']; + + $postie = "A user replied to your post: " . $postieP; + $stmt = $db->prepare("INSERT INTO main.comment (username, targetType, targetId, date, content, id) VALUES (?,?,?,?,?,?)"); + $stmt->execute([$user10,'notification',$posts2,microtime(true) - $ref,$postie,bin2hex(random_bytes(16))]); + } getOut($postType,$postId); } diff --git a/docs/notif.php b/docs/notif.php new file mode 100644 index 0000000..c7a0995 --- /dev/null +++ b/docs/notif.php @@ -0,0 +1,11 @@ + diff --git a/libs/page.php b/libs/page.php index 74744ab..5d242d6 100755 --- a/libs/page.php +++ b/libs/page.php @@ -17,6 +17,7 @@ + Pings Logout Login