summaryrefslogtreecommitdiff
path: root/www/functions
diff options
context:
space:
mode:
authorroot2014-03-21 11:56:08 +0100
committerroot2014-03-21 11:56:08 +0100
commit08e945b89d649759f40916877f40044657314d9a (patch)
tree6f10dcab815df5ba9c2b6878a73835a147efa07e /www/functions
parentfe561fa106699a0a2e8e20633efed855c33f85c6 (diff)
downloadfiles.iamfabulous.de-08e945b89d649759f40916877f40044657314d9a.tar.gz
If you are loged in, now you can download your files.
Diffstat (limited to 'www/functions')
-rwxr-xr-xwww/functions/func_content.php12
-rw-r--r--www/functions/func_download.php12
-rwxr-xr-xwww/functions/func_interface.php17
-rwxr-xr-xwww/functions/func_register.php2
4 files changed, 36 insertions, 7 deletions
diff --git a/www/functions/func_content.php b/www/functions/func_content.php
index 9500f06..f7c4629 100755
--- a/www/functions/func_content.php
+++ b/www/functions/func_content.php
@@ -19,6 +19,18 @@ function get_content($db, $file_id, $owner){
$count++;
}
+/*
+ var_dump($content); exit;
+ if($content[0][4] == "FILE"){
+ if(!start_file_download($username, $folder_path)){
+ echo "False!"; exit;
+ return false;
+ } else {
+ echo "True!"; exit;
+ return true;
+ }
+ }
+*/
if(!empty($content)){
return $content; // returns everything listed in the folder which is commited as parameter
} else {
diff --git a/www/functions/func_download.php b/www/functions/func_download.php
index 035e5b4..83db597 100644
--- a/www/functions/func_download.php
+++ b/www/functions/func_download.php
@@ -2,6 +2,7 @@
/*
Expected state: tested, broken.
+ Works if you are loged in, fatal error if not.
*/
function start_file_download($user, $path){
@@ -66,15 +67,16 @@ function download_file($db, $file_id){
$uploaddir = "../files/";
$gzip_file = $uploaddir . $file_hash . ".gz";
- $uncompressed_file = readgzfile($gzip_file);
- if($uncompressed_file){
+
+ //if($uncompressed_file){
header("Content-Type: ".$file_mime);
header("Content-Disposition: attachment; filename=\"".$file_name."\"");
+ $uncompressed_file = readgzfile($gzip_file);
return true;
- } else {
- return false;
- }
+ //} else {
+ // return false;
+ //}
}
diff --git a/www/functions/func_interface.php b/www/functions/func_interface.php
index 0c765f4..192e94f 100755
--- a/www/functions/func_interface.php
+++ b/www/functions/func_interface.php
@@ -9,7 +9,22 @@ function collect_content($db,$username, $folder_path){
$file_id = select_file_id($db, $owner, $folder_path);
- $content = get_content($db, $file_id, $owner);
+ $check_if_file_db = $db->query("SELECT folder FROM files WHERE id=".$file_id.";");
+ $check_if_file_ar = $check_if_file_db->fetchArray(SQLITE3_NUM);
+
+ //TODO: Instead of exit; let the browser start_download or print folder content
+ if($check_if_file_ar[0] == "FILE"){
+ if(start_file_download($username, $folder_path)){
+ exit;
+ return true;
+ } else {
+ exit;
+ return false;
+ }
+ } else {
+ $content = get_content($db, $file_id, $owner);
+ }
+
/*if(!$content){
failure("This folder is empty.");
diff --git a/www/functions/func_register.php b/www/functions/func_register.php
index be8c197..b87d81f 100755
--- a/www/functions/func_register.php
+++ b/www/functions/func_register.php
@@ -22,7 +22,7 @@ function register($db){
/*Checks the validation of the registration attempt*/
$test_db = $db->query("SELECT 1,key,status FROM user WHERE email='" . $safe_email . "';");
- $test_ar = $test_status_db->fetchArray(SQLITE3_NUM);
+ $test_ar = $test_db->fetchArray(SQLITE3_NUM);
$test_email = $test_ar[0];
$test_key = $test_ar[1];
$test_status_int = $test_ar[2];