Skip to content

Commit

Permalink
apiv2 siteurl fix for fetch_posts
Browse files Browse the repository at this point in the history
  • Loading branch information
ksportalcraft committed Nov 11, 2024
1 parent 0d0a12f commit 5d34074
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions apiv2/fetch_posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

function getPostsFromDatabase($username = null, $page = 1, $postsPerPage = 16, $disablePagination = false) {
include("../important/db.php");
global $siteurl;

$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);

Expand Down Expand Up @@ -47,8 +46,8 @@ function getPostsFromDatabase($username = null, $page = 1, $postsPerPage = 16, $
$plus_one = isset($post['plus_one']) ? $post['plus_one'] + 1 : 1;

$comments = getCommentsForPost($post['id']);
$profile_image_url = $siteurl . "/apiv1/fetch_pfp_api.php?username=" . urlencode($comment['username']);
$profile_image_url = $siteurl . "/apiv1/fetch_pfp_api.php?name=" . urlencode($post['username']);

$posts[] = array(
'id' => $post['id'],
'username' => $post['username'],
Expand All @@ -60,8 +59,8 @@ function getPostsFromDatabase($username = null, $page = 1, $postsPerPage = 16, $
'created_at' => $post['created_at'],
'plus_one' => $plus_one,
'plus_one_usernames' => $post['plus_one_usernames'],
'profile_image_url' => $profile_image_url,
'comments' => $comments,
'profile_image_url' => $profile_image_url
);
}

Expand Down Expand Up @@ -92,7 +91,7 @@ function getCommentsForPost($post_id) {

while ($comment = $result->fetch_assoc()) {

$profile_image_url = $siteurl . "/apiv1/fetch_pfp_api.php?username=" . urlencode($comment['username']);
$profile_image_url = $siteurl . "/apiv1/fetch_pfp_api.php?name=" . urlencode($comment['username']);

$comments[] = array(
'username' => $comment['username'],
Expand Down

0 comments on commit 5d34074

Please sign in to comment.