From 11f7f219b72c909cdbf74426e5095d9ee3ef8ec8 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Wed, 12 Mar 2014 19:32:07 +0100 Subject: fixed PHP's bug with empty() --- www/functions/func_select.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'www/functions/func_select.php') diff --git a/www/functions/func_select.php b/www/functions/func_select.php index dc649f2..4a803b2 100644 --- a/www/functions/func_select.php +++ b/www/functions/func_select.php @@ -13,21 +13,21 @@ function select($db){ } $owner_db = $db->query("SELECT id FROM user WHERE name='" . SQLite3::escapeString($user) . "';"); - if(empty($owner_db)){ + $owner_ar = $owner_db->fetchArray(SQLITE3_NUM); + if(empty($owner_ar)){ failure("This user doesn't exist."); } - $owner_ar = $owner_db->fetchArray(SQLITE3_NUM); $owner = $owner_ar[0]; $folder_array_unsafe = explode("/",$_GET["folder"]); $length = count($folder_array_unsafe); $root_db = $db->query("SELECT id FROM files WHERE parent=0 AND owner=" . $owner . " AND folder='DIRECTORY' " . $share . ";"); - if(empty($root_db)){ + $root_ar = $root_db->fetchArray(SQLITE3_NUM); + if(empty($root_ar)){ failure("There is something seriously wrong. If you are a human you should never read this. Mail the admin please."); } - $root_ar = $root_db->fetchArray(SQLITE3_NUM); $root_id = $root_ar[0]; $parentdir = SQLite3::escapeString($root_id); $temp_id = $root_id; @@ -36,10 +36,12 @@ function select($db){ if(!empty($folder_array_unsafe[$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($parentdir_db)){ + + $prim_id = $parentdir_db->fetchArray(SQLITE3_NUM); + if(empty($prim_id)){ failure("Database error."); } - $prim_id = $parentdir_db->fetchArray(SQLITE3_NUM); + if($parentdir != $prim_id[1]){ $wrong_folder = $folder_array_unsafe[$i]; @@ -70,7 +72,6 @@ function select($db){ $content[$count][6] = $row[6]; $content[$count][7] = $row[7]; $content[$count][8] = $row[8]; - //echo "" . $content[$count][3] . "
"; $count++; } -- cgit v1.2.3