Переглянути джерело

Added validation to the path and the file if exists, when is empty for the tests CT#191

Arthur Portugal 15 роки тому
батько
коміт
107eeda8f7
1 змінених файлів з 11 додано та 11 видалено
  1. 11 11
      main/inc/lib/fileManage.lib.php

+ 11 - 11
main/inc/lib/fileManage.lib.php

@@ -410,21 +410,21 @@ function copyDirTo($origDirPath, $destination, $move=true)
 
 function index_dir($path)
 {
-	
-	
-	
 	$save_dir = getcwd();
-	chdir($path);
-	$handle = opendir($path);
+	if(is_dir($path)){
+		chdir($path);
+		$handle = opendir($path);
+	}
 	// reads directory content end record subdirectoies names in $dir_array
-	while ($element = readdir($handle) )
-	{
-		if ( $element == "." || $element == "..") continue;	// skip the current and parent directories
-		if ( is_dir($element) )	 $dirArray[] = $path."/".$element;
+	if (file_exists($handle)) {
+		while ($element = readdir($handle) )
+		{
+			if ( $element == "." || $element == "..") continue;	// skip the current and parent directories
+			if ( is_dir($element) )	 $dirArray[] = $path."/".$element;
+		}
+		closedir($handle) ;
 	}
 
-	closedir($handle) ;
-
 	// recursive operation if subdirectories exist
 	$dirNumber = sizeof($dirArray);
 	if ( $dirNumber > 0 )