From c526938c960524e8e79124890875cd7afeae1d7f Mon Sep 17 00:00:00 2001 From: moehm Date: Wed, 19 Mar 2014 17:39:48 +0100 Subject: Added func_download and func_delete. --- www/functions/func_download.php | 67 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 www/functions/func_download.php (limited to 'www/functions/func_download.php') diff --git a/www/functions/func_download.php b/www/functions/func_download.php new file mode 100644 index 0000000..91c8085 --- /dev/null +++ b/www/functions/func_download.php @@ -0,0 +1,67 @@ +query("SELECT id, owner, share FROM files WHERE parent=" . $folder_id . "); + $file_id_ar = $file_id_db->fetchArray(SQLITE3_NUM); + $file_id = $file_id_ar[0]; + + $check_verification_db = $ + $check_verification_ar[1]; + $share = $check_verification_ar[2]; + + + if($_SESSION["login"] && ($_SESSION["userid"] == $file_owner)){ + $var = download_file($db, $file_id); + } else { + if($share != "PUBLIC"){ + return false; + } + + $var = download_file($db, $file_id); + } +*/ + + $var = download_file($db, $file_id); + + return $var; +} + +function check_file_hash($db, $file_id, $download_hash){ + $check_hash_db = $db->query("SELECT share FROM files WHERE id=" . SQLite3::escapeString($file_id).";"); + $check_hash_ar = $check_hash_db->fetchArray(SQLITE3_NUM); + + if(($check_hash_ar[0] != "PUBLIC") || ($check_hash_ar[0] != $download_hash)){ + return false; + } + + $var = download_file($db, $file_id); + return $var; + +} + +function download_file($db, $file_id){ + + $file_db = $db->query("SELECT name, mime, hash FROM files WHERE id=". SQLite3::escapeString($file_id).";"); + $file_ar = $file_db->fetchArray(SQLITE3_NUM); + $file_name = $file_ar[0]; + $file_mime = $file_ar[1]; + $file_hash = $file_ar[2]; + + $uploaddir = "../files/"; + $gzip_file = $uploaddir . $file_hash . ".gz"; + $fp = gzopen($gzip_file, '') // TODO: DECOMPRESS CONSTANT + + //TODO GZIP DECOMPRESSION + + //TODO set HTTP HEADER + + return true; + +} -- cgit v1.2.3