Created
March 24, 2022 19:36
-
-
Save DaltonWebDev/3158f1c5ea8942063550170377983016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dfLatest($member) { | |
global $conn; | |
global $date; | |
$following = listFollowing($member); | |
if ($following === false) { | |
return false; | |
} else { | |
foreach ($following as $object) { | |
$memberId = $object["author"]; | |
$statusId = $object["status_id"]; | |
if (likeExists($member, $statusId)) { | |
// let's remove this status! | |
} else if (skipExists($member, $statusId)) { | |
// let's remove this status | |
} else if (commentExists($member, $statusId)) { | |
// let's remove this status | |
} else { | |
$array = $object; | |
break; | |
} | |
} | |
if (!isset($array)) { | |
return false; | |
} else { | |
return $array; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sessionId = !empty($_REQUEST["session_id"]) ? strtolower($_REQUEST["session_id"]) : false; | |
$distractionFree = !empty($_REQUEST["distraction_free"]) ? strtolower($_REQUEST["distraction_free"]) : false; | |
if ($sessionId !== false) { | |
$memberId = verifySession($sessionId); | |
$data["authed_username"] = getUsername($memberId); | |
} | |
if ($sessionId === false) { | |
$error = [ | |
"code" => "SESSION_ID_MISSING", | |
"message" => getDictionary("SESSION_ID_MISSING") | |
]; | |
} else if ($memberId === false) { | |
$error = [ | |
"code" => "INVALID_SESSION", | |
"message" => getDictionary("INVALID_SESSION") | |
]; | |
} else { | |
$data["notification_count"] = count(listNotifications($memberId)); | |
$data["letter_count"] = count(listLetters($memberId, 0)); | |
$data["pro"] = isPro($memberId); | |
if ($distractionFree === false) { | |
$result = homeFeed($memberId); | |
if ($result === false) { | |
$data["username"] = getUsername($memberId); | |
$error = [ | |
"code" => "NO_STATUSES", | |
"message" => getDictionary("NO_STATUSES") | |
]; | |
} else { | |
$x = 0; | |
$data["username"] = getUsername($memberId); | |
foreach ($result as $object) { | |
$result[$x]["status"] = $Parsedown->text(strip_tags($result[$x]["status"])); | |
$result[$x]["username"] = getUsername($object["member_id"]); | |
$result[$x]["name"] = getProfileName($object["member_id"]); | |
$result[$x]["verified"] = isVerified($object["member_id"]); | |
$result[$x]["pro"] = isPro($object["member_id"]); | |
$result[$x]["pronouns"] = getPronouns($object["member_id"]); | |
$result[$x]["profile_picture"] = getProfilePicture($object["member_id"]); | |
$result[$x]["timestamp"] = $object["timestamp"]; | |
if (getMetricsHidden($memberId) == 2) { | |
$result[$x]["likes"] = ""; | |
$result[$x]["likers"] = false; | |
$result[$x]["comments"] = ""; | |
} else { | |
$result[$x]["likes"] = countStatusLikes($object["status_id"]); | |
$result[$x]["likers"] = listLikes($object["status_id"]); | |
$result[$x]["comments"] = countStatusComments($object["status_id"]); | |
} | |
$result[$x]["liked"] = likeExists($memberId, $object["status_id"]); | |
$x++; | |
} | |
$error = false; | |
$data["posts"] = $result; | |
} | |
} else { | |
$result = dfLatest($memberId); | |
$data["username"] = getUsername($memberId); | |
if ($result === false) { | |
$error = [ | |
"code" => "NO_STATUSES", | |
"message" => getDictionary("NO_STATUSES") | |
]; | |
} else { | |
$error = false; | |
$data["post"] = $result; | |
$data["post"]["status"] = $Parsedown->text(strip_tags($data["post"]["status"])); | |
$data["post"]["username"] = getUsername($result["author"]); | |
$data["post"]["name"] = getProfileName($result["author"]); | |
$data["post"]["verified"] = isVerified($result["author"]); | |
$data["post"]["pro"] = isPro($result["author"]); | |
$data["post"]["pronouns"] = getPronouns($result["author"]); | |
$data["post"]["profile_picture"] = getProfilePicture($result["author"]); | |
$data["post"]["timestamp"] = humanTiming(strtotime($result["date"])); | |
if (getMetricsHidden($memberId) == 2) { | |
$data["post"]["likes"] = ""; | |
$data["post"]["likers"] = false; | |
$data["post"]["comments"] = ""; | |
} else { | |
$data["post"]["likes"] = countStatusLikes($result["status_id"]); | |
$data["post"]["likers"] = listLikes($result["status_id"]); | |
$data["post"]["comments"] = countStatusComments($result["status_id"]); | |
} | |
$data["post"]["liked"] = likeExists($memberId, $result["status_id"]); | |
} | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function homeFeed($member) { | |
global $conn; | |
global $date; | |
$following = listFollowingAndYourself($member); | |
if ($following === false) { | |
return false; | |
} else { | |
foreach ($following as $object) { | |
$memberId = $object["author"]; | |
$statusId = $object["status_id"]; | |
$status = $object["status"]; | |
$statusDate = $object["date"]; | |
$array[] = [ | |
"username" => getUsername($memberId), | |
"member_id" => $memberId, | |
"status_id" => $statusId, | |
"status" => $status, | |
"timestamp" => humanTiming(strtotime($statusDate)) | |
]; | |
} | |
if (!isset($array)) { | |
return []; | |
} else { | |
return $array; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment