diff options
author | Minteck <contact@minteck.org> | 2022-04-12 16:22:44 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-04-12 16:22:44 +0200 |
commit | f5d140a3ef6e34658f6a9a6cc58ee32d01427782 (patch) | |
tree | 665bfe2da70c032fc7c8f24def802ae0a8b0bae2 /file | |
parent | 300ab1d94c7d476a6c87f1d32d1756d8b04e3dbf (diff) | |
download | cloudsdale-f5d140a3ef6e34658f6a9a6cc58ee32d01427782.tar.gz cloudsdale-f5d140a3ef6e34658f6a9a6cc58ee32d01427782.tar.bz2 cloudsdale-f5d140a3ef6e34658f6a9a6cc58ee32d01427782.zip |
File uploader
Diffstat (limited to 'file')
-rw-r--r-- | file/index.php | 41 |
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 |