diff options
| author | moehm | 2014-03-20 13:11:59 +0100 |
|---|---|---|
| committer | moehm | 2014-03-20 13:11:59 +0100 |
| commit | 96757d7ef1294344c2f196346b3d73a3515d7e54 (patch) | |
| tree | 8fd4eeeb9afc2ec17195d0b6675a13cc980dea7a /www/functions | |
| parent | bafaf5fad9266612c172c58360587832b8edb1b9 (diff) | |
| download | files.iamfabulous.de-96757d7ef1294344c2f196346b3d73a3515d7e54.tar.gz | |
Finished func_download.
Diffstat (limited to 'www/functions')
| -rw-r--r-- | www/functions/func_delete.php | 4 | ||||
| -rw-r--r-- | www/functions/func_download.php | 30 |
2 files changed, 25 insertions, 9 deletions
diff --git a/www/functions/func_delete.php b/www/functions/func_delete.php index 821f1aa..aaf6e3e 100644 --- a/www/functions/func_delete.php +++ b/www/functions/func_delete.php @@ -1,5 +1,9 @@ <?php +/* + expected state: broken +*/ + function delete_file($user, $path){ if(!$_SESSION["login"]){ diff --git a/www/functions/func_download.php b/www/functions/func_download.php index 91c8085..9b3a489 100644 --- a/www/functions/func_download.php +++ b/www/functions/func_download.php @@ -1,5 +1,9 @@ <?php +/* + Expected state: broken. +*/ + function start_file_download($user, $path){ $db = $GLOBALS["db"]; @@ -28,9 +32,11 @@ function start_file_download($user, $path){ } */ - $var = download_file($db, $file_id); - - return $var; + if(!download_file($db, $file_id)){ + return false; + } else { + return true; + } } function check_file_hash($db, $file_id, $download_hash){ @@ -41,8 +47,11 @@ function check_file_hash($db, $file_id, $download_hash){ return false; } - $var = download_file($db, $file_id); - return $var; + if(!download_file($db, $file_id)){ + return false; + } else { + return true; + } } @@ -56,11 +65,14 @@ function download_file($db, $file_id){ $uploaddir = "../files/"; $gzip_file = $uploaddir . $file_hash . ".gz"; - $fp = gzopen($gzip_file, '') // TODO: DECOMPRESS CONSTANT + $fp = gzopen($gzip_file, 'r') + $uncompressed_file = gzread($fp, filesize($fp)); - //TODO GZIP DECOMPRESSION - - //TODO set HTTP HEADER + header("Content-Type: ".$file_mime); + header("Content-Disposition: attachment; filename=\"".$file_name."\""); + if(!readfile($uncompressed_file)){ + return false; + } return true; |
