summaryrefslogtreecommitdiff
path: root/api/get_image.php
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-03-27 21:29:24 +0200
committerMinteck <contact@minteck.org>2022-03-27 21:29:24 +0200
commit226516aca48e97d3dc4e4df213bc2023e64b1afd (patch)
tree60fb4f24b75b120e7e5b0e149069b16367c48aa0 /api/get_image.php
downloadargon-226516aca48e97d3dc4e4df213bc2023e64b1afd.tar.gz
argon-226516aca48e97d3dc4e4df213bc2023e64b1afd.tar.bz2
argon-226516aca48e97d3dc4e4df213bc2023e64b1afd.zip
Initial commit
Diffstat (limited to 'api/get_image.php')
-rw-r--r--api/get_image.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/api/get_image.php b/api/get_image.php
new file mode 100644
index 0000000..e8ea59f
--- /dev/null
+++ b/api/get_image.php
@@ -0,0 +1,20 @@
+<?php
+
+if (isset($_GET["_"])) {
+ $f = trim($_GET["_"]);
+} else {
+ die();
+}
+
+header("Content-Type: image/png");
+
+if (str_contains($f, "/") || str_contains($f, ".") || trim($f) === "") die();
+$f = str_replace(":", "-", $f);
+
+if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/images/" . $f . ".png")) {
+ $url = $_SERVER['DOCUMENT_ROOT'] . "/data/images/" . $f . ".png";
+} else {
+ $url = "https://www.gravatar.com/avatar/" . md5($f) . "?f=y&d=identicon&s=256";
+}
+
+die(file_get_contents($url)); \ No newline at end of file