diff options
| author | root | 2014-04-14 08:35:13 +0200 |
|---|---|---|
| committer | root | 2014-04-14 08:35:13 +0200 |
| commit | 12734da8826299ffd24c0a15f6dbf205892d7221 (patch) | |
| tree | 3b894dd30e332df23a564ce44e42ce164c8abd78 /www/functions/notused/func_content.php | |
| parent | 7b9d516cd3bcdb8eaa5f1eb533d71010061c681b (diff) | |
| download | jungegemeinde-12734da8826299ffd24c0a15f6dbf205892d7221.tar.gz | |
Pushed to v3
Diffstat (limited to 'www/functions/notused/func_content.php')
| -rwxr-xr-x | www/functions/notused/func_content.php | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/www/functions/notused/func_content.php b/www/functions/notused/func_content.php new file mode 100755 index 0000000..ad0c87e --- /dev/null +++ b/www/functions/notused/func_content.php @@ -0,0 +1,121 @@ +<?php + +function collect_content($db,$username, $folder_path){ + $owner = user_id($db, $username); + + if(!$owner){ + failure("This user doesn't exist!"); + } + + $file_id = select_file_id($db, $owner, $folder_path); + + if(!$file_id){ + return FILE_NOT_FOUND; + } + + $content = get_content($db, $file_id, $owner); + + if(!$content){ + return EMPTY_FOLDER; + } + + return $content; +} + +function get_content($db, $file_id, $owner){ + + if($_SESSION["login"] && $_SESSION["userid"] == $owner){ + $share=""; + } else { + $share =" AND share='PUBLIC'"; + } + + $content_db = $db->query("SELECT * FROM files WHERE parent=" . $file_id . " AND owner=" . $owner . $share . " ORDER BY folder, name;"); + + $count=0; + + while($row = $content_db->fetchArray(SQLITE3_NUM)){ + $content[$count][0] = $row[0]; + $content[$count][1] = $row[1]; + $content[$count][2] = $row[2]; + $content[$count][3] = $row[3]; + $content[$count][4] = $row[4]; + $content[$count][5] = $row[5]; + $content[$count][6] = $row[6]; + $content[$count][7] = $row[7]; + $content[$count][8] = $row[8]; + $count++; + } + + 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_wrong_folder($db, $username, $folder_path){ + + $owner = user_id($db, $username); + + if($_SESSION["login"] && $_SESSION["userid"] == $owner){ + $share = ""; + } 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 folder='DIRECTORY' " . $share . ";"); + $root_ar = $root_db->fetchArray(SQLITE3_NUM); + $root_id = $root_ar[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); + + 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; + + 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_wrong_folder($content){ + + $length = count($content); + + $wrong_folder = $content[$length-1]; + $working_path[0] = $wrong_folder; // initialize empty array + + for($i=0; $i<$length-1; $i++){ + $working_path[$i] = $content[$i]; + } + + get_404($working_path, $wrong_folder); +} |
