aboutsummaryrefslogtreecommitdiff
path: root/file/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'file/index.php')
-rw-r--r--file/index.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/file/index.php b/file/index.php
new file mode 100644
index 0000000..9b1f250
--- /dev/null
+++ b/file/index.php
@@ -0,0 +1,41 @@
+<?php
+
+$keys = array_keys($_GET);
+
+if (isset($keys[0])) {
+ $id = $keys[0];
+} else {
+ die();
+}
+
+if (str_contains($id, "/") || str_contains($id, ".")) {
+ die();
+}
+
+if (trim($id) === "") {
+ die();
+}
+
+$data = json_decode(file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/data/files.json"), true);
+
+$name = $id . ".bin";
+foreach ($data as $item) {
+ if ($item["uuid"] === $id) {
+ $name = $item["name"];
+ }
+}
+
+$file = $_SERVER['DOCUMENT_ROOT'] . "/data/uploads/" . $id;
+
+header('Content-Description: File Transfer');
+header('Content-Type: ' . mime_content_type($file));
+header('Content-Disposition: filename="' . $name . '"');
+header('Content-Transfer-Encoding: binary');
+header('Content-Length: ' . filesize($file));
+header('Expires: 0');
+header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+header('Pragma: public');
+ob_clean();
+flush();
+readfile($file);
+exit; \ No newline at end of file