Moritz Schmidt пре 10 година
родитељ
комит
3b4304cc5c
2 измењених фајлова са 18 додато и 11 уклоњено
  1. 14 11
      includes/functions.inc.php
  2. 4 0
      includes/label.inc.php

+ 14 - 11
includes/functions.inc.php

@@ -66,20 +66,23 @@ function handleFile($filename, &$allDocuments) {
 		}
 	} else {
 		$found = false;
-		foreach($allDocuments as $key => $document) {
-			if($document['fileName'] == explode('/', $filename)[sizeof(explode('/', $filename)) - 1]) {
-				$labelPath = Label::getLabelByID($document['labelID'])->getPath();
 
+		if($allDocuments) {
+			foreach($allDocuments as $key => $document) {
+				if($document['fileName'] == explode('/', $filename)[sizeof(explode('/', $filename)) - 1]) {
+					$labelPath = Label::getLabelByID($document['labelID'])->getPath();
 
-				if(str_replace($CONFIG['documentPath'], "", $filename) == $labelPath . "/" . $document['path'] . $document['fileName']) {
-					// found
-					// update stuff
-					unset($allDocuments[$key]); // remove from array
-					$found = true;
-					break;
-				}
 
-				// same filename, path unknown
+					if(str_replace($CONFIG['documentPath'], "", $filename) == $labelPath . "/" . $document['path'] . $document['fileName']) {
+						// found
+						// update stuff
+						unset($allDocuments[$key]); // remove from array
+						$found = true;
+						break;
+					}
+
+					// same filename, path unknown
+				}
 			}
 		}
 

+ 4 - 0
includes/label.inc.php

@@ -90,6 +90,10 @@ class Label {
         $return = array();
         $labels = $db->selectQuery("SELECT * FROM `labels` WHERE `path` = '" . $path . "';");
 
+        if(!$labels) {
+            return false;
+        }
+
         foreach($labels as $label) {
             $return[] = new Label($label->id, $label->name, $label->path);
         }