From e61e581a2b66b0444db01d884465ea913929e343 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Tue, 31 Oct 2023 17:04:34 +0100 Subject: Updated 27 files, added 12 files and deleted 3 files (automated) --- profile/index.php | 418 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 418 insertions(+) create mode 100644 profile/index.php (limited to 'profile') diff --git a/profile/index.php b/profile/index.php new file mode 100644 index 0000000..1fb6ac3 --- /dev/null +++ b/profile/index.php @@ -0,0 +1,418 @@ += 0) { + return $tense = "now"; + } elseif ($difference > 0) { + $tense = "ago"; + } else { + $tense = "later"; + } + + for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { + $difference /= $lengths[$j]; + } + + $difference = round($difference); + + $period = $periods[$j]; + + if ($showTense) { + if ($long) { + return "{$difference} {$period}" . ($difference > 1 ? "s" : "") . " {$tense}"; + } else { + return "{$difference} {$period} {$tense}"; + } + } else { + if ($long) { + return "{$difference} {$period}" . ($difference > 1 ? "s" : ""); + } else { + return "{$difference} {$period}"; + } + } +} + +global $_PROFILE; +$_PROFILE = null; + +if (isset($_COOKIE["WAVY_SESSION_TOKEN"])) { + if (!str_contains($_COOKIE["WAVY_SESSION_TOKEN"], ".") && !str_contains($_COOKIE["WAVY_SESSION_TOKEN"], "/")) { + if (str_starts_with($_COOKIE["WAVY_SESSION_TOKEN"], "wv_")) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE["WAVY_SESSION_TOKEN"])) { + $_PROFILE = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/tokens/" . $_COOKIE["WAVY_SESSION_TOKEN"]), true); + } + } + } +} + +$available = false; +global $userPrivacy; + +$userProfile = []; +$userFavorites = []; +$userHistory = []; +$userLibrary = []; +$userSettings = []; + +if (count($_GET) > 0 && str_starts_with(array_keys($_GET)[0], "/")) { + $hasID = true; + $selectedId = substr(array_keys($_GET)[0], 1); + + if (preg_match("/[^a-f0-9-]/m", $selectedId) == 0) { + if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $selectedId . "-privacy.json")) { + $userPrivacy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $selectedId . "-privacy.json"), true); + $userProfile = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $selectedId . "-profile.json"), true); + + if ($userPrivacy["profile"] >= 1 && isset($_PROFILE) || $userPrivacy["profile"] === 2 || $_PROFILE["id"] === $userProfile["id"]) { + $available = true; + + $userFavorites = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $selectedId . "-favorites.json"), true); + $userHistory = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $selectedId . "-history.json"), true); + $userLibrary = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $selectedId . "-library.json"), true); + $userSettings = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $selectedId . "-profileSettings.json"), true); + + $userLibrary = array_values(array_filter($userLibrary, function ($i) { + global $albums; + return isset($albums[$i]); + })); + $userHistory = array_values(array_filter($userHistory, function ($i) { + global $songs; + return isset($songs[$i["item"]]); + })); + $userFavorites = array_values(array_filter($userFavorites, function ($i) { + global $songs; + return isset($songs[$i]); + })); + } + } + } +} else { + $hasID = false; +} + +if (!$available && $hasID) { + header("HTTP/1.1 404 Not Found"); +} + +function allowed(string $item): bool { + global $userPrivacy; global $userProfile; global $_PROFILE; + return $userPrivacy[$item] >= 1 && isset($_PROFILE) || $userPrivacy[$item] === 2 || $_PROFILE["id"] === $userProfile["id"]; +} + +?> + + + + + + + + <?= $available ? $userProfile['name'] . " — Mist" : "Mist" ?> + + + + + + + + + + + + + + " /> + " /> + " /> + "> + + " /> + " /> + + " /> + + + +
+ + "> + ?dpr=2&size=32" style="filter: none !important; border-radius: 999px; vertical-align: middle; width: 32px;"> + + + Sign in + +
+ + + + + + + + + +