diff options
Diffstat (limited to 'www/functions/func_download.php')
| -rw-r--r-- | www/functions/func_download.php | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/www/functions/func_download.php b/www/functions/func_download.php index 9b3a489..035e5b4 100644 --- a/www/functions/func_download.php +++ b/www/functions/func_download.php @@ -1,7 +1,7 @@ <?php /* - Expected state: broken. + Expected state: tested, broken. */ function start_file_download($user, $path){ @@ -10,7 +10,7 @@ function start_file_download($user, $path){ $owner = user_id($db, $user); - $file_id = select_file_id($db, $owner, $path) + $file_id = select_file_id($db, $owner, $path); /* $file_id_db = $db->query("SELECT id, owner, share FROM files WHERE parent=" . $folder_id . "); $file_id_ar = $file_id_db->fetchArray(SQLITE3_NUM); @@ -65,15 +65,16 @@ function download_file($db, $file_id){ $uploaddir = "../files/"; $gzip_file = $uploaddir . $file_hash . ".gz"; - $fp = gzopen($gzip_file, 'r') - $uncompressed_file = gzread($fp, filesize($fp)); - header("Content-Type: ".$file_mime); - header("Content-Disposition: attachment; filename=\"".$file_name."\""); - if(!readfile($uncompressed_file)){ + $uncompressed_file = readgzfile($gzip_file); + + if($uncompressed_file){ + header("Content-Type: ".$file_mime); + header("Content-Disposition: attachment; filename=\"".$file_name."\""); + return true; + } else { return false; } - return true; } |
