diff --git a/docs/api/comment.php b/docs/api/comment.php new file mode 100644 index 0000000..49f9a5c --- /dev/null +++ b/docs/api/comment.php @@ -0,0 +1,76 @@ + 1024) { + getOut($postType,$postId); + } + if (is_uploaded_file($_FILES['file']['tmp_name'])) { + $fid = bin2hex(random_bytes(16)); + + $type = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); + + $type = strtolower($type); + + $mime = mime_content_type('test' . $type); + + $legal = ['png','gif','jpeg','jpg','mp4','webm','mp3','wav']; + + if (in_array($type, $legal)) { + move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . '/../docs/pic/' . $fid . '.' . $type); + $postie .= "\nhttps://" . $_SERVER['HTTP_HOST'] . '/pic/' . $fid . '.' . $type; + } + } + + $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,$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); + } + + post_handler(); +?> diff --git a/docs/auth.php b/docs/auth.php index 9b49252..1f995db 100644 --- a/docs/auth.php +++ b/docs/auth.php @@ -1,5 +1,5 @@ diff --git a/docs/comment.php b/docs/comment.php index 418aa96..4935cb9 100644 --- a/docs/comment.php +++ b/docs/comment.php @@ -1,7 +1,7 @@ 1024) { - getOut($postType,$postId); - } - if (is_uploaded_file($_FILES['file']['tmp_name'])) { - $fid = bin2hex(random_bytes(16)); - - $type = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION); - - $type = strtolower($type); - - $mime = mime_content_type('test' . $type); - - $legal = ['png','gif','jpeg','jpg','mp4','webm','mp3','wav']; - - if (in_array($type, $legal)) { - move_uploaded_file($_FILES['file']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . '/../docs/pic/' . $fid . '.' . $type); - $postie .= "\nhttps://" . $_SERVER['HTTP_HOST'] . '/pic/' . $fid . '.' . $type; - } - } - - $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,$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); - } - - post_handler(); page_header(); ?> diff --git a/docs/login.php b/docs/login.php index c7e7620..74546e8 100755 --- a/docs/login.php +++ b/docs/login.php @@ -1,6 +1,6 @@ $value ) @@ -10,4 +10,4 @@ die(); } page_footer(); -?> \ No newline at end of file +?> diff --git a/docs/notif.php b/docs/notif.php index b1060d3..e6f2323 100644 --- a/docs/notif.php +++ b/docs/notif.php @@ -1,7 +1,7 @@ \ No newline at end of file +?> diff --git a/docs/tou.php b/docs/tou.php index 3bd59d3..8603f62 100755 --- a/docs/tou.php +++ b/docs/tou.php @@ -1,5 +1,5 @@ diff --git a/docs/user.php b/docs/user.php index 9ab7ce9..eca2c32 100755 --- a/docs/user.php +++ b/docs/user.php @@ -1,7 +1,7 @@ '','type' => 'hidden','name' => 'type', 'default' => $typer), array('key' => '','type' => 'hidden','name' => 'id', 'default' => $idr), array('key' => 'Attachments', 'type' => 'file', 'name' => 'file', 'default' => '') - ),'/index.php'); + ),'/api/comment.php'); } $qs = parse_url($_SERVER['REQUEST_URI']); diff --git a/libs/page.php b/libs/page.php index 5d242d6..cbbc59e 100755 --- a/libs/page.php +++ b/libs/page.php @@ -1,5 +1,5 @@ diff --git a/scripts/init.php b/scripts/init.php index 5fa3c4e..3eeccfc 100755 --- a/scripts/init.php +++ b/scripts/init.php @@ -1,5 +1,5 @@ exec($sql); echo "Database was set up."; -?> \ No newline at end of file +?>