diff options
Diffstat (limited to 'www/functions/func_content.php')
| -rwxr-xr-x | www/functions/func_content.php | 27 |
1 files changed, 17 insertions, 10 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]; } |
