summaryrefslogtreecommitdiff
path: root/includes/util/functions.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/util/functions.inc')
-rw-r--r--includes/util/functions.inc30
1 files changed, 29 insertions, 1 deletions
diff --git a/includes/util/functions.inc b/includes/util/functions.inc
index 87954ea..b01476f 100644
--- a/includes/util/functions.inc
+++ b/includes/util/functions.inc
@@ -23,6 +23,16 @@ if (!function_exists("getMemberPronouns")) {
}
}
+if (!function_exists("file_get_contents_or_defaults")) {
+ function file_get_contents_or_defaults($file, $default) {
+ if (file_exists($file)) {
+ return file_get_contents($file);
+ } else {
+ return $default;
+ }
+ }
+}
+
if (!function_exists("parseMetadata")) {
function parseMetadata ($metadata) {
$metadata["little"] = 0;
@@ -106,6 +116,24 @@ if (!function_exists("peh_error")) {
if (!function_exists("getAsset")) {
function getAsset($systemID, $memberID = null, $type = "avatars"): string {
+ if ($systemID === "gdapd") {
+ if (isset($memberID)) {
+ if ($type === "avatars" || $type === "heads") {
+ return getSystemMember($systemID, $memberID)["avatar_url"];
+ } else {
+ return getSystemMember($systemID, $memberID)["banner"];
+ }
+ } else {
+ $system = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/" . $systemID . "/general.json"), true);
+
+ if ($type === "avatars" || $type === "heads") {
+ return $system["avatar_url"];
+ } else {
+ return $system["banner"];
+ }
+ }
+ }
+
$app = $GLOBALS["ColdHazeApp"] ?? json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
$systemFile = (isset($app["other"]) && $systemID === $app["other"]["id"]) ? "other" : $systemID;
@@ -660,4 +688,4 @@ if (!function_exists("calculateFullAmount")) {
return number_format($total, 2, '.', ',');
}
}
-} \ No newline at end of file
+}