summaryrefslogtreecommitdiff
path: root/handoff/avatar/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'handoff/avatar/index.php')
-rw-r--r--handoff/avatar/index.php121
1 files changed, 0 insertions, 121 deletions
diff --git a/handoff/avatar/index.php b/handoff/avatar/index.php
deleted file mode 100644
index baf6519..0000000
--- a/handoff/avatar/index.php
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-
-function imageCreateCorners($sourceImageFile, $radius) {
- # test source image
- if (file_exists($sourceImageFile)) {
- $res = is_array($info = getimagesize($sourceImageFile));
- }
- else $res = false;
-
- # open image
- if ($res) {
- $w = $info[0];
- $h = $info[1];
- switch ($info['mime']) {
- case 'image/jpeg': $src = imagecreatefromjpeg($sourceImageFile);
- break;
- case 'image/gif': $src = imagecreatefromgif($sourceImageFile);
- break;
- case 'image/png': $src = imagecreatefrompng($sourceImageFile);
- break;
- default:
- $res = false;
- }
- }
-
- # create corners
- if ($res) {
-
- $q = 10; # change this if you want
- $radius *= $q;
-
- # find unique color
- do {
- $r = rand(0, 255);
- $g = rand(0, 255);
- $b = rand(0, 255);
- }
- while (imagecolorexact($src, $r, $g, $b) < 0);
-
- $nw = $w*$q;
- $nh = $h*$q;
-
- $img = imagecreatetruecolor($nw, $nh);
- $alphacolor = imagecolorallocatealpha($img, $r, $g, $b, 127);
- imagealphablending($img, false);
- imagesavealpha($img, true);
- imagefilledrectangle($img, 0, 0, $nw, $nh, $alphacolor);
-
- imagefill($img, 0, 0, $alphacolor);
- imagecopyresampled($img, $src, 0, 0, 0, 0, $nw, $nh, $w, $h);
-
- imagearc($img, $radius-1, $radius-1, $radius*2, $radius*2, 180, 270, $alphacolor);
- imagefilltoborder($img, 0, 0, $alphacolor, $alphacolor);
- imagearc($img, $nw-$radius, $radius-1, $radius*2, $radius*2, 270, 0, $alphacolor);
- imagefilltoborder($img, $nw-1, 0, $alphacolor, $alphacolor);
- imagearc($img, $radius-1, $nh-$radius, $radius*2, $radius*2, 90, 180, $alphacolor);
- imagefilltoborder($img, 0, $nh-1, $alphacolor, $alphacolor);
- imagearc($img, $nw-$radius, $nh-$radius, $radius*2, $radius*2, 0, 90, $alphacolor);
- imagefilltoborder($img, $nw-1, $nh-1, $alphacolor, $alphacolor);
- imagealphablending($img, true);
- imagecolortransparent($img, $alphacolor);
-
- # resize image down
- $dest = imagecreatetruecolor($w, $h);
- imagealphablending($dest, false);
- imagesavealpha($dest, true);
- imagefilledrectangle($dest, 0, 0, $w, $h, $alphacolor);
- imagecopyresampled($dest, $img, 0, 0, 0, 0, $w, $h, $nw, $nh);
-
- # output image
- $res = $dest;
- imagedestroy($src);
- imagedestroy($img);
- }
-
- return $res;
-}
-
-$api = true;
-$data = [
- "loggedIn" => false
-];
-
-if (isset($_GET["token"])) {
- $_COOKIE["DeltaSession"] = $_GET["token"];
-}
-
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $_USER; global $_PROFILE;
-
-if ($data["loggedIn"] && file_exists($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $_USER . ".webp")) {
- header("Content-Type: image/png");
- $id = bin2hex(random_bytes(32));
- $out = [];
- $out2 = [];
-
- $size = getimagesize($_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $_USER . ".webp");
-
- exec('convert -size 128x128 xc:none -draw "roundrectangle 0,0,128,128,128,128" /tmp/' . $id . '-mask.png', $out);
-
- exec('convert -resize 128x128 "' . $_SERVER['DOCUMENT_ROOT'] . "/uploads/" . $_USER . ".webp" . '" /tmp/' . $id . '-source.png');
- exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask.png -compose DstIn -composite /tmp/' . $id . '.png', $out2);
-
- if ($_PROFILE["plus"]) {
- exec('convert -background none -bordercolor none -resize 94x94 -border 17x17 /tmp/' . $id . '.png /tmp/' . $id . '-source.png');
-
- if ($_PROFILE["ultra"]) {
- exec('convert -background none /tmp/' . $id . '-source.png "' . $_SERVER['DOCUMENT_ROOT'] . '/circle-ultra.png" -gravity Center -composite /tmp/' . $id . '.png');
- } else {
- exec('convert -background none /tmp/' . $id . '-source.png "' . $_SERVER['DOCUMENT_ROOT'] . '/circle-plus.png" -gravity Center -composite /tmp/' . $id . '.png');
- }
- }
-
- echo(file_get_contents('/tmp/' . $id . '.png'));
- unlink('/tmp/' . $id . '.png');
- unlink('/tmp/' . $id . '-mask.png');
- unlink('/tmp/' . $id . '-source.png');
-} else {
- header("Content-Type: image/png");
-
- die(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/defaultuser.png"));
-} \ No newline at end of file