summaryrefslogtreecommitdiff
path: root/www/functions
diff options
context:
space:
mode:
authorHorus32014-04-21 20:26:26 +0200
committerHorus32014-04-21 20:26:26 +0200
commit1301304d2ea739f550738e0fafc56d74a65905f4 (patch)
treee309ae34480b6f768c086ca685c8d56c0c95b266 /www/functions
parentdef084a19a19e1d5c77600c0c0967e5a8fed5b93 (diff)
downloadfiles.iamfabulous.de-1301304d2ea739f550738e0fafc56d74a65905f4.tar.gz
Added documentation for class and new methods.
Diffstat (limited to 'www/functions')
-rwxr-xr-xwww/functions/func_content.php3
-rw-r--r--www/functions/func_download.php30
2 files changed, 18 insertions, 15 deletions
diff --git a/www/functions/func_content.php b/www/functions/func_content.php
index ad0c87e..853adc1 100755
--- a/www/functions/func_content.php
+++ b/www/functions/func_content.php
@@ -44,6 +44,9 @@ function get_content($db, $file_id, $owner){
$content[$count][6] = $row[6];
$content[$count][7] = $row[7];
$content[$count][8] = $row[8];
+ $content[$count][9] = $row[9];
+ $content[$count][10] = $row[10];
+ $content[$count][11] = $row[11];
$count++;
}
diff --git a/www/functions/func_download.php b/www/functions/func_download.php
index 576320c..2b4acc5 100644
--- a/www/functions/func_download.php
+++ b/www/functions/func_download.php
@@ -39,9 +39,10 @@ function start_file_download($user, $path){
$file_ar = $file_db->fetchArray(SQLITE3_NUM);
$file_owner = $file_ar[0];
$share = $file_ar[1];
+ $force_download = false;
if($_SESSION["login"] && ($_SESSION["userid"] == $file_owner)){
- if(download_file($db, $file_id)){
+ if(download_file($db, $file_id, $force_download)){
return true;
} else {
return false;
@@ -51,7 +52,7 @@ function start_file_download($user, $path){
return false;
}
- if(download_file($db, $file_id)){
+ if(download_file($db, $file_id, $force_download)){
return true;
} else {
return false;
@@ -67,7 +68,7 @@ function check_file_hash($db, $file_id, $download_hash){
$check_hash_db = $db->query("SELECT owner, folder, share, download_link FROM files WHERE id=" . SQLite3::escapeString($file_id).";");
$check_hash_ar = $check_hash_db->fetchArray(SQLITE3_NUM);
- if($check_hash_ar[1] != "FILE"){
+ if($check_hash_ar[1] != "FILE" || !$check_hash_ar){
return DOWNLOAD_NOT_FILE;
}
@@ -79,15 +80,18 @@ function check_file_hash($db, $file_id, $download_hash){
}
}
- if(!download_file($db, $file_id)){
- return false;
- } else {
+ $force_download = true;
+
+ $var = download_file($db, $file_id, $force_download);
+ if($var){
return true;
+ } else {
+ return $var;
}
}
-function download_file($db, $file_id){
+function download_file($db, $file_id, $force_download){
$file_db = $db->query("SELECT name, mime, size, hash FROM files WHERE id=". SQLite3::escapeString($file_id).";");
$file_ar = $file_db->fetchArray(SQLITE3_NUM);
@@ -102,15 +106,13 @@ function download_file($db, $file_id){
//TODO: buffer output, print if reading == true
- header("Content-Type: ".$file_mime);
-/*
- if(!preg_match("/^image\/.+/", $file_mime)){
+ header("Content-Type: ".$file_mime."");
+ if(preg_match("/^application\/.+/", $file_mime) || $force_download){
header("Content-Disposition: attachment; filename=\"".$file_name."\"");
} else {
- header("filename=".$file_name."");
+ header('filename="'.$file_name.'"');
}
-*/
- header("filename=".$file_name."");
+
header("Content-Length: ".$file_size);
set_time_limit(0);
$uncompressed_file = readgzfile($gzip_file);
@@ -121,6 +123,4 @@ function download_file($db, $file_id){
} else {
return false;
}
-
-
}