From 29928887e733f3bc2c2baaf06dafd495a006753b Mon Sep 17 00:00:00 2001 From: Minteck Date: Fri, 3 Mar 2023 07:04:02 +0100 Subject: Updated 18 files and added 10 files (automated) --- pages/api/ponytown.php | 117 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 pages/api/ponytown.php (limited to 'pages/api') diff --git a/pages/api/ponytown.php b/pages/api/ponytown.php new file mode 100644 index 0000000..f41ac01 --- /dev/null +++ b/pages/api/ponytown.php @@ -0,0 +1,117 @@ + 70) { + $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } + + if ($_ === 1 && $size[1] > 70) { + $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } + + if ($_ === 2 && $size[0] > 35) { + $errors[] = "0x{$_}000002A: Image #" . $_ . " is wider than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } + + if ($_ === 2 && $size[1] > 35) { + $errors[] = "0x{$_}000002B: Image #" . $_ . " is higher than it should, are you sure you set zoom to 1x? Maybe you inverted the files?"; + } +} + +if (count($errors) === 0 && isset($_GET["real"])) { + foreach ([1, 2] as $_) { + $input = $json_object[$_ - 1]; + + $mime = explode(";", substr($input, 5))[0]; + $file = base64_decode(explode(",", explode(";", substr($input, 5))[1])[1]); + + $image = @imagecreatefromstring($file); + + imagealphablending($image, false); + imagesavealpha($image, true); + + if ($_ === 1) { + imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/ponies/" . $member["id"] . ".png"); + } else { + imagepng($image, $_SERVER['DOCUMENT_ROOT'] . "/assets/uploads/pt-" . $member["name"] . ".png"); + } + } +} + +die(json_encode([ + "success" => count($errors) === 0, + "errors" => $errors +])); \ No newline at end of file -- cgit