summaryrefslogtreecommitdiff
path: root/www/functions
diff options
context:
space:
mode:
authorroot2014-03-22 02:14:04 +0100
committerroot2014-03-22 02:14:04 +0100
commitf1840d40760abb9869bd218ca510eceb94f86478 (patch)
tree5e7afdd68c2e639bfa89c91fa3da07749b4fc093 /www/functions
parent296d8a14511739a15327ffe30c0895cd3490e940 (diff)
downloadfiles.iamfabulous.de-f1840d40760abb9869bd218ca510eceb94f86478.tar.gz
Differences between folder_is_empty and file_not_found. TODO: Extra design for empty folder.
Diffstat (limited to 'www/functions')
-rwxr-xr-xwww/functions/func_content.php27
-rw-r--r--www/functions/func_download.php6
-rwxr-xr-xwww/functions/func_select.php6
3 files changed, 22 insertions, 17 deletions
diff --git a/www/functions/func_content.php b/www/functions/func_content.php
index 8431c15..c405715 100755
--- a/www/functions/func_content.php
+++ b/www/functions/func_content.php
@@ -10,12 +10,14 @@ function collect_content($db,$username, $folder_path){
$file_id = select_file_id($db, $owner, $folder_path);
if(!$file_id){
- print_empty_folder($db, $username, $folder_path);
- echo "Empty folder";
- exit;
+ return FILE_NOT_FOUND;
}
$content = get_content($db, $file_id, $owner);
+
+ if(!$content){
+ return EMPTY_FOLDER;
+ }
return $content;
}
@@ -52,7 +54,7 @@ function get_content($db, $file_id, $owner){
}
}
-function get_path_to_empty_folder($db, $username, $folder_path){
+function get_path_to_wrong_folder($db, $username, $folder_path){
$owner = user_id($db, $username);
@@ -65,18 +67,16 @@ function get_path_to_empty_folder($db, $username, $folder_path){
$folder_array_unsafe = explode("/",$folder_path);
$length = count($folder_array_unsafe);
- //echo "SELECT id FROM files WHERE parent=0 AND owner=" . SQLite3::escapeString($owner) . " AND folder='DIRECTORY' " . $share . ";"; exit;
-
$root_db = $db->query("SELECT id FROM files WHERE parent=0 AND owner=" . SQLite3::escapeString($owner) . " AND folder='DIRECTORY' " . $share . ";");
$root_ar = $root_db->fetchArray(SQLITE3_NUM);
$root_id = $root_ar[0];
- if(empty($root_id[0])){
+ if(empty($root_id)){
return FOLDER_NOT_PUBLIC;
}
$parentdir = $root_id;
-
+
for($i=0; $i<$length; $i++){
$parentdir_db = $db->query("SELECT id, parent FROM files WHERE owner=" . $owner . $share . " AND parent=". $parentdir . " AND name='" . SQLite3::escapeString($folder_array_unsafe[$i]) . "';");
$prim_id = $parentdir_db->fetchArray(SQLITE3_NUM);
@@ -92,21 +92,28 @@ function get_path_to_empty_folder($db, $username, $folder_path){
$lwp = count($working_path);
$working_path[$lwp] = $wrong_folder;
+ if($i == 0){
+ $working_path[0] = ""; // shows just the root slash
+ }
+
return $working_path; // returns working path and wrong folder as an array
}
+ $parentdir = $prim_id[0];
+
}
return false;
}
-function print_empty_folder($content){
+function print_wrong_folder($content){
+
$length = count($content);
$wrong_folder = $content[$length-1];
$working_path[0] = $wrong_folder; // initialize empty array
- for($i=0; $i<$length-2; $i++){
+ for($i=0; $i<$length-1; $i++){
$working_path[$i] = $content[$i];
}
diff --git a/www/functions/func_download.php b/www/functions/func_download.php
index 64ca335..5770da4 100644
--- a/www/functions/func_download.php
+++ b/www/functions/func_download.php
@@ -21,10 +21,9 @@ function check_if_file($db, $name, $folder_path){
return false;
}
} else {
- $content = get_path_to_empty_folder($db, $name, $folder_path);
- print_empty_folder($content);
+ //$content = get_path_to_empty_folder($db, $name, $folder_path);
+ //print_empty_folder($content);
//get_404("/", "Protected file");
- exit;
return false;
}
@@ -83,6 +82,7 @@ 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];
diff --git a/www/functions/func_select.php b/www/functions/func_select.php
index 53f1fa6..ae76121 100755
--- a/www/functions/func_select.php
+++ b/www/functions/func_select.php
@@ -30,8 +30,6 @@ function select_file_id($db, $owner, $folder_path){
return $root_id; // returns the primary key from the root dir
}
- //echo "Länge: ".$length." ".var_dump($folder_array_unsafe); exit;
-
for($i=0; $i<$length; $i++){
$parentdir_db = $db->query("SELECT id, parent FROM files WHERE owner=" . $owner . $share . " AND parent=" . $parentdir . " AND name='" . SQLite3::escapeString($folder_array_unsafe[$i]) . "';");
@@ -51,14 +49,14 @@ function select_file_id($db, $owner, $folder_path){
get_404($working_path, $wrong_folder);
*/
+
return false;
}
+
$parentdir = $prim_id[0];
- var_dump($parentdir); echo "func_select, during for";
}
- //var_dump($parentdir); echo "func_select, after for"; exit;
return $parentdir; // returns the primary key from the last entry in the folder array
}