diff options
Diffstat (limited to 'www/functions/func_select.php')
| -rw-r--r-- | www/functions/func_select.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/www/functions/func_select.php b/www/functions/func_select.php index 0659cdb..46afd46 100644 --- a/www/functions/func_select.php +++ b/www/functions/func_select.php @@ -7,6 +7,11 @@ function select($db, $owner){ $share ="AND share='PUBLIC'"; } + if(empty($_GET["folder"])){ + $_GET["folder"] = "/"; + } + + $folder_array_unsafe = explode("/",$_GET["folder"]); $length = count($folder_array_unsafe); @@ -19,16 +24,22 @@ function select($db, $owner){ $parentdir = SQLite3::escapeString($root_id); $temp_id = $root_id; - if(empty($folder_array_unsafe[$i])){ - + if(empty($folder_array_unsafe)){ + return $root_id; } + for($i=0; $i<$length; $i++){ $parentdir_db = $db->query("SELECT id, parent FROM files WHERE owner=" . $owner . " AND folder='DIRECTORY' " . $share . " AND parent=" . $parentdir . " AND name='" . SQLite3::escapeString($folder_array_unsafe[$i]) . "';"); + if(empty($folder_array_unsafe[$i])){ + return $parentdir; + } + $prim_id = $parentdir_db->fetchArray(SQLITE3_NUM); if(empty($prim_id)){ failure("Database error."); + echo $prim_id; } if($parentdir != $prim_id[1]){ |
