aboutsummaryrefslogtreecommitdiff
path: root/www/functions/notused/func_select.php
diff options
context:
space:
mode:
authorroot2014-04-14 08:35:13 +0200
committerroot2014-04-14 08:35:13 +0200
commit12734da8826299ffd24c0a15f6dbf205892d7221 (patch)
tree3b894dd30e332df23a564ce44e42ce164c8abd78 /www/functions/notused/func_select.php
parent7b9d516cd3bcdb8eaa5f1eb533d71010061c681b (diff)
downloadjungegemeinde-12734da8826299ffd24c0a15f6dbf205892d7221.tar.gz
Pushed to v3
Diffstat (limited to 'www/functions/notused/func_select.php')
-rwxr-xr-xwww/functions/notused/func_select.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/www/functions/notused/func_select.php b/www/functions/notused/func_select.php
new file mode 100755
index 0000000..9f10cd6
--- /dev/null
+++ b/www/functions/notused/func_select.php
@@ -0,0 +1,62 @@
+<?php
+function select_file_id($db, $owner, $folder_path){
+
+ if($_SESSION["login"] && $_SESSION["userid"] == $owner){ // TODO: Check if loged in user really the user who does the query - fix 12.3.14
+ $share=""; // to print all files, even hidden ones
+ } else {
+ $share =" AND share='PUBLIC'"; // just use files with the correct permissions
+ }
+
+ $folder_array_unsafe = explode("/",$folder_path);
+
+ $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_ar[0])){
+ failure("Seems like the user doesn't want to show his tree: " . $root_id);
+ }
+
+ $tmp_length = count($folder_array_unsafe);
+
+ if(empty($folder_array_unsafe[$tmp_length-1])){
+ $length = $tmp_length-1;
+ } else {
+ $length = $tmp_length;
+ }
+
+ $parentdir = SQLite3::escapeString($root_id);
+
+ if(empty($folder_array_unsafe[0])){
+ return $root_id; // returns the primary key from the root dir
+ }
+
+ 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]) . "' COLLATE NOCASE;");
+
+ $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];
+ }
+
+ get_404($working_path, $wrong_folder);
+*/
+
+ return false;
+ }
+
+
+ $parentdir = $prim_id[0];
+ }
+
+ return $parentdir; // returns the primary key from the last entry in the folder array
+
+}