diff options
Diffstat (limited to 'includes/assets.inc')
-rw-r--r-- | includes/assets.inc | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/includes/assets.inc b/includes/assets.inc new file mode 100644 index 0000000..9a0a9ac --- /dev/null +++ b/includes/assets.inc @@ -0,0 +1,55 @@ +<?php + +if (!file_exists("../assets/avatars")) mkdir("../assets/avatars"); +if (!file_exists("../assets/banners")) mkdir("../assets/banners"); +if (!file_exists("../assets/heads")) mkdir("../assets/heads"); +if (!file_exists("../assets/bodies")) mkdir("../assets/bodies"); + +function downloadAssets($system) { + $general = json_decode(file_get_contents("./data/$system/general.json"), true); + + if (isset($general["avatar_url"])) { + $id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]); + echo(" /avatars/$id.webp\n"); + exec("convert -resize 512x512 \"" . $general["avatar_url"] . "\" ../assets/avatars/" . $id . ".webp"); + exec("convert -resize 512x512 \"" . $general["avatar_url"] . "\" ../assets/uploads/" . ($id === "gdapd" ? "raindrops" : "cloudburst") . ".png"); + } + + if (isset($general["banner"])) { + $id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]); + echo(" /banners/$id.webp\n"); + exec("convert -resize 2048x2048 \"" . $general["banner"] . "\" ../assets/banners/" . $id . ".webp"); + } + + $members = json_decode(file_get_contents("./data/$system/members.json"), true); + + foreach ($members as $member) { + $id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]) . preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $member["uuid"]); + + if (isset($member["avatar_url"])) { + echo(" /avatars/$id.webp\n"); + exec("convert -resize 512x512 \"" . $member["avatar_url"] . "\" ../assets/avatars/" . $id . ".webp"); + } + + if (isset($member["banner"])) { + echo(" /banners/$id.webp\n"); + exec("convert -resize 2048x2048 \"" . $member["banner"] . "\" ../assets/banners/" . $id . ".webp"); + } + + if (file_exists("../assets/uploads/pt-" . $member["name"] . ".png")) { + $url = "../assets/uploads/pt-" . $member["name"] . ".png"; + } else { + $url = "../assets/uploads/pt.png"; + } + echo(" /heads/$id.webp\n"); + exec("convert -resize 64x64 \"" . $url . "\" ../assets/heads/" . $id . ".webp"); + + if (file_exists("../app/fronters/ponies/" . $member["id"] . ".png")) { + echo(" /bodies/$id.webp\n"); + exec("convert -resize 128x128 \"" . "../app/fronters/ponies/" . $member["id"] . ".png" . "\" ../assets/bodies/" . $id . ".webp"); + } + } +} + +downloadAssets("gdapd"); +downloadAssets("ynmuc");
\ No newline at end of file |