diff options
author | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-13 12:51:47 +0200 |
---|---|---|
committer | Alex Vitkov <alexvitkov98@gmail.com> | 2021-02-13 12:51:47 +0200 |
commit | 3ab8276b269b3d646d232cf093d13bb280e28bf7 (patch) | |
tree | f7c775cb9b2c9ed3e5bb3ed973b4c1fdf7b0b77d /php/readfile.php | |
parent | 0c56b6431133facf94f83faf920cfa58e311dd19 (diff) | |
download | fileup-3ab8276b269b3d646d232cf093d13bb280e28bf7.tar.gz |
/php/readfile.php
Diffstat (limited to 'php/readfile.php')
-rw-r--r-- | php/readfile.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/php/readfile.php b/php/readfile.php index d978ffc..6e759d3 100644 --- a/php/readfile.php +++ b/php/readfile.php @@ -6,7 +6,7 @@ require_once "node.php"; require_once "misc.php"; session_start(); -if (!isset($_POST["filename"]) || !isset($_FILES["folder"])) { +if (!isset($_POST["filename"]) || !isset($_POST["folder"])) { error_log("/php/readfile.php - invalid request"); http_response_code(400); exit(1); @@ -19,7 +19,7 @@ $filename = $_POST["filename"]; $dir = get_directory($folder, $user); if (!$dir) { - error_log("i/php/readfile.php - invalid directory"); + error_log("/php/readfile.php - invalid directory"); http_response_code(409); exit(0); } @@ -30,7 +30,15 @@ $file_node = null; foreach ($contents_of_dir as $c) { if ($c['name'] == $filename) { $file_node = $c; + break; } } +if (!$file_node) { + error_log("/php/readfile.php - invalid filename"); + http_response_code(409); + exit(0); +} + +header("Content-type: $file_node[mimetype]"); -var_error_log($file_node); +readfile("$storage_root/$file_node[code]"); |