diff options
-rw-r--r-- | api/raindrops-img-round.php | 94 | ||||
-rw-r--r-- | assets/uploads/pt-forestpaint.png | bin | 0 -> 3633 bytes | |||
-rw-r--r-- | pages/thinkpad.inc | 50 |
3 files changed, 144 insertions, 0 deletions
diff --git a/api/raindrops-img-round.php b/api/raindrops-img-round.php new file mode 100644 index 0000000..af4acbe --- /dev/null +++ b/api/raindrops-img-round.php @@ -0,0 +1,94 @@ +<?php + +$fronters = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/fronters.json"), true); + +$url = isset($fronters['members'][0]) ? ($fronters['members'][0]["avatar_url"] ?? "https://static.equestria.horse/ponies/uploads/raindrops.png") : "https://static.equestria.horse/ponies/uploads/raindrops.png"; +file_put_contents("/tmp/temp", file_get_contents($url)); + +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; +} + +header("Content-Type: image/png"); + +$id = bin2hex(random_bytes(8)); +exec('convert -size 128x128 xc:none -draw "roundrectangle 0,0,128,128,128,128" /tmp/' . $id . '-mask.png', $out); + +exec('convert -resize 128x128 "/tmp/temp" /tmp/' . $id . '-source.png'); +exec('convert /tmp/' . $id . '-source.png -matte /tmp/' . $id . '-mask.png -compose DstIn -composite /tmp/' . $id . '.png', $out2); + +unlink("/tmp/temp"); + +echo(file_get_contents('/tmp/' . $id . '.png'));
\ No newline at end of file diff --git a/assets/uploads/pt-forestpaint.png b/assets/uploads/pt-forestpaint.png Binary files differnew file mode 100644 index 0000000..639da8b --- /dev/null +++ b/assets/uploads/pt-forestpaint.png diff --git a/pages/thinkpad.inc b/pages/thinkpad.inc new file mode 100644 index 0000000..af1bcfa --- /dev/null +++ b/pages/thinkpad.inc @@ -0,0 +1,50 @@ +<?php + +// 2:20 + +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; +require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; + +$password = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["thinkpad"]["password"]; +$mac = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true)["thinkpad"]["mac"]; +$error = ""; +$success = ""; + +if (isset($_POST["submit"]) && isset($_POST["pwd"])) { + if (password_verify($_POST["pwd"], $password)) { + $out = []; + exec("bash -c '/usr/sbin/ether-wake " . $mac . "'", $out); + + if (count($out) === 0) { + $success = "Successfully turned laptop on, please wait 5 minutes before connecting to it, and don't forget to turn it back off afterwards you dork"; + } else { + $error = "Failed to initiate Wake on LAN message: " . implode(", ", $out); + } + } else { + $error = "Invalid password, I am going to burn down your house if you're trying to touch my laptop"; + } +} + +?> + +<br> +<div class="container"> + <div id="page-content"> + <h2>ThinkPad</h2> + + <?php if (trim($error) !== ""): ?> + <div class="alert alert-danger"><b>Error:</b> <?= $error ?></div> + <?php endif; ?> + <?php if (trim($success) !== ""): ?> + <div class="alert alert-success"><b>Success:</b> <?= $success ?></div> + <?php endif; ?> + + <form method="post"> + <input type="hidden" name="submit" action="/-/thinkpad"> + <p><input type="password" name="pwd" class="form-control" placeholder="Password" style="filter: invert(1) hue-rotate(180deg);"></p> + <button class="btn btn-primary">Flip the switch!</button> + </form> + </div> +</div> + +<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?> |