From cd7aeaef26bf05e42e789da6bc4a97118c40d616 Mon Sep 17 00:00:00 2001 From: moehm Date: Fri, 21 Mar 2014 18:40:44 +0100 Subject: The index.php starts the download. Also extra function to print empty folders. --- www/functions/func_content.php | 87 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 12 deletions(-) (limited to 'www/functions/func_content.php') diff --git a/www/functions/func_content.php b/www/functions/func_content.php index f7c4629..c750554 100755 --- a/www/functions/func_content.php +++ b/www/functions/func_content.php @@ -1,5 +1,23 @@ query("SELECT * FROM files WHERE parent=" . $file_id . " AND owner=" . $owner . ";"); @@ -19,21 +37,66 @@ 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 { return false; // empty folder } } + +function get_path_to_empty_folder($db, $username, $folder_path){ + + if($_SESSION["login"] && $_SESSION["userid"] == $owner){ + if($_SESSION["login"] && $_SESSION["userid"] == $owner){} + } else { + $share ="AND share='PUBLIC'"; + } + + $folder_array_unsafe = explode("/",$folder_path); + $length = count($folder_array_unsafe); + + $root_db = $db->query("SELECT id FROM files WHERE parent=0 AND owner=" . SQLite3::escapeString($owner) . " AND fo lder='DIRECTORY' " . $share . ";"); + $root_ar = $root_db->fetchArray(SQLITE3_NUM); + $root_id = $root_ar[0]; + + if(empty($root_id[0])){ + return 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); + + if($parentdir != $prim_id[1]){ + $wrong_folder = $folder_array_unsafe[$i]; + $working_path[0] = $wrong_folder; + + for($j=0; $j<$i; $j++){ + $working_path[$j] = $folder_array_unsafe[$j]; + } + + $lwp = count($working_path); + $working_path[$lwp] = $wrong_folder; + + return $working_path; // returns working path and wrong folder as an array + } + + } + + return false; +} + +function print_empty_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++){ + $working_path[$i] = $content[$i]; + } + + get_404($working_path, $wrong_folder); +} -- cgit v1.2.3