summaryrefslogtreecommitdiff
path: root/www/functions/func_download.php
diff options
context:
space:
mode:
authorroot2014-03-20 14:17:13 +0100
committerroot2014-03-20 14:17:13 +0100
commitfe561fa106699a0a2e8e20633efed855c33f85c6 (patch)
treef81a0cf71304a7bfc311037206c1c5684602b459 /www/functions/func_download.php
parent96757d7ef1294344c2f196346b3d73a3515d7e54 (diff)
downloadfiles.iamfabulous.de-fe561fa106699a0a2e8e20633efed855c33f85c6.tar.gz
First test for download() and delete().
Diffstat (limited to 'www/functions/func_download.php')
-rw-r--r--www/functions/func_download.php17
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;
}