diff options
author | RaindropsSys <contact@minteck.org> | 2023-03-12 19:16:53 +0100 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-03-12 19:16:53 +0100 |
commit | eb89b15c0f044673c1206a418a21d0baba1a675e (patch) | |
tree | 39ac31a576d8b8392cbd9baf8d67621bf2cefa86 /includes/assets.inc | |
parent | 5385f0ed8fbb4325203a222a75e6700ffb519349 (diff) | |
download | pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.tar.gz pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.tar.bz2 pluralconnect-eb89b15c0f044673c1206a418a21d0baba1a675e.zip |
Updated 104 files, added 3 files, deleted 4 files and renamed 36 files (automated)
Diffstat (limited to 'includes/assets.inc')
-rw-r--r-- | includes/assets.inc | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/includes/assets.inc b/includes/assets.inc deleted file mode 100644 index 3f2d652..0000000 --- a/includes/assets.inc +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -global $app; - -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, $path = null) { - if (!isset($path)) { - $path = $system; - } - - $general = json_decode(file_get_contents("./data/$path/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"); - file_put_contents("/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION), file_get_contents($general['avatar_url'])); - exec("convert -resize 512x512 \"" . "/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION) . "\" ../assets/avatars/" . $id . ".webp"); - unlink("/tmp/img." . pathinfo($general['avatar_url'], PATHINFO_EXTENSION)); - } - - 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"); - file_put_contents("/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION), file_get_contents($general['banner'])); - exec("convert -resize 2048x2048 \"" . "/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION) ."\" ../assets/banners/" . $id . ".webp"); - unlink("/tmp/img." . pathinfo($general['banner'], PATHINFO_EXTENSION)); - } - - $members = json_decode(file_get_contents("./data/$path/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"); - file_put_contents("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION), file_get_contents($member['avatar_url'])); - exec("convert -resize 512x512 \"" . "/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION) . "\" ../assets/avatars/" . $id . ".webp"); - unlink("/tmp/img." . pathinfo($member['avatar_url'], PATHINFO_EXTENSION)); - } - - echo(" /banners/$id.webp\n"); - - if (isset($member["banner"])) { - file_put_contents("/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION), file_get_contents($member['banner'])); - exec("convert -resize 2048x2048 \"" . "/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION) . "\" ../assets/banners/" . $id . ".webp"); - unlink("/tmp/img." . pathinfo($member['banner'], PATHINFO_EXTENSION)); - } else { - $img = imagecreate(2048, 1024); - - if (isset($member["color"])) { - imagecolorallocate($img, hexdec(substr($member["color"], 0, 2)) / 2, hexdec(substr($member["color"], 2, 2)) / 2, hexdec(substr($member["color"], 4, 2)) / 2); - } else { - imagecolorallocate($img, 0, 0, 0); - } - - imagejpeg($img, "/tmp/img.jpeg", 100); - imagedestroy($img); - exec("convert -resize 2048x2048 \"/tmp/img.jpeg\" ../assets/banners/" . $id . ".webp"); - unlink("/tmp/img.jpeg"); - } - - 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.png\n"); - exec("convert \"" . $url . "\" ../assets/heads/" . $id . ".png"); - - if (file_exists("../assets/ponies/" . $member["id"] . ".png")) { - echo(" /bodies/$id.png\n"); - exec("convert \"" . "../assets/ponies/" . $member["id"] . ".png" . "\" ../assets/bodies/" . $id . ".png"); - } - } -} - -downloadAssets("gdapd"); -downloadAssets("ynmuc"); - -if (isset($app["other"]) && isset($app["other"]["id"]) && isset($app["other"]["token"])) { - downloadAssets($app["other"]["id"], "other"); -}
\ No newline at end of file |