Exclude directories now
[mailer.git] / inc / functions.php
index c227a23925e6d5069a84a1108ea06b4c353727d4..9060a90193d3f85512b0599ca1a7a87efe22a99b 100644 (file)
@@ -1854,7 +1854,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = FALSE, $ad
                                if ($addBaseDir === TRUE) {
                                        // With base path
                                        array_push($foundMatches, $fileName);
-                               } elseif ($withPrefixSuffix === FALSE) {
+                               } elseif (($withPrefixSuffix === FALSE) && (!empty($extension))) {
                                        // No prefix/suffix
                                        array_push($foundMatches, substr($baseFile, strlen($prefix), -strlen($suffix . $extension)));
                                } else {
@@ -1865,9 +1865,18 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = FALSE, $ad
                                // We found .php file but should not search for them, why?
                                reportBug(__FUNCTION__, __LINE__, 'We should find files with extension=' . $extension . ', but we found a PHP script. (baseFile=' . $baseFile . ')');
                        }
-               } elseif (($fileExtension == $extension) || (empty($extension))) {
+               } elseif ((($fileExtension == $extension) || (empty($extension))) && (isFileReadable($FQFN))) {
                        // Other, generic file found
-                       array_push($foundMatches, $fileName);
+                       if ($addBaseDir === TRUE) {
+                               // With base path
+                               array_push($foundMatches, $fileName);
+                       } elseif (($withPrefixSuffix === FALSE) && (!empty($extension))) {
+                               // No prefix/suffix
+                               array_push($foundMatches, substr($baseFile, strlen($prefix), -strlen($suffix . $extension)));
+                       } else {
+                               // No base path
+                               array_push($foundMatches, $baseFile);
+                       }
                }
        } // END - while