X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=f35ee954c60d3d74e065fbe730f9f71980a696bd;hb=e46c5fea5c110ad9bb1514d2c92a60b140f28f70;hp=393c44efcfb732ca570b7328bdc6112fcbfb53ee;hpb=56f65abf076605702654332aceb55d5c275d336f;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index 393c44efcf..f35ee954c6 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -767,7 +767,7 @@ function createFancyTime ($stamp) { foreach ($data as $k => $v) { if ($v > 0) { // Value is greater than 0 "eval" data to return string - $ret .= ', ' . $v . ' {--_' . strtoupper($k) . '--}'; + $ret .= ', ' . $v . ' {%pipe,translateTimeUnit=' . $k . '%}'; break; } // END - if } // END - foreach @@ -778,7 +778,7 @@ function createFancyTime ($stamp) { $ret = substr($ret, 2); } else { // Zero seconds - $ret = '0 {--_SECONDS--}'; + $ret = '0 {--TIME_UNIT_SECOND--}'; } // Return fancy time string @@ -801,7 +801,7 @@ function isEmailValid ($email) { } // Function taken from user comments on www.php.net / function isInStringIgnoreCase() -function isUrlValid ($url, $compile=true) { +function isUrlValid ($url, $compile = true) { // Trim URL a little $url = trim(urldecode($url)); //* DEBUG: */ debugOutput($url); @@ -1793,19 +1793,32 @@ function isExtraTitleSet () { return ((isset($GLOBALS['extra_title'])) && (!empty($GLOBALS['extra_title']))); } -// Reads a directory recursively by default and searches for files not matching -// an exclusion pattern. You can now keep the exclusion pattern empty for reading -// a whole directory. +/** + * Reads a directory recursively by default and searches for files not matching + * an exclusion pattern. You can now keep the exclusion pattern empty for reading + * a whole directory. + * + * @param $baseDir Relative base directory to PATH to scan from + * @param $prefix Prefix for all positive matches (which files should be found) + * @param $fileIncludeDirs Wether to include directories in the final output array + * @param $addBaseDir Wether to add $baseDir to all array entries + * @param $excludeArray Excluded files and directories, these must be full files names, e.g. 'what-' will exclude all files named 'what-' but won't exclude 'what-foo.php' + * @param $extension File extension for all positive matches + * @param $excludePattern Regular expression to exclude more files (preg_match()) + * @param $recursive Wether to scan recursively + * @param $suffix Suffix for positive matches ($extension will be appended, too) + * @return $foundMatches All found positive matches for above criteria + */ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $addBaseDir = true, $excludeArray = array(), $extension = '.php', $excludePattern = '@(\.|\.\.)$@', $recursive = true, $suffix = '') { - // Add default entries we should exclude - $excludeArray[] = '.'; - $excludeArray[] = '..'; - $excludeArray[] = '.svn'; - $excludeArray[] = '.htaccess'; + // Add default entries we should always exclude + $excludeArray[] = '.'; // Current directory + $excludeArray[] = '..'; // Parent directory + $excludeArray[] = '.svn'; // Directories created by Subversion + $excludeArray[] = '.htaccess'; // Directory protection files (mostly) //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'baseDir=' . $baseDir . ',prefix=' . $prefix . ' - Entered!'); - // Init includes - $files = array(); + // Init found includes + $foundMatches = array(); // Open directory $dirPointer = opendir(getPath() . $baseDir) or debug_report_bug(__FUNCTION__, __LINE__, 'Cannot read directory ' . basename($baseDir) . '.'); @@ -1828,10 +1841,8 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Check if the base filenname matches an exclusion pattern and if the pattern is not empty if ((!empty($excludePattern)) && (preg_match($excludePattern, $baseFile, $match))) { - // These Lines are only for debugging!! - //* DEBUG: */ debugOutput('baseDir:' . $baseDir); - //* DEBUG: */ debugOutput('baseFile:' . $baseFile); - //* DEBUG: */ debugOutput('FQFN:' . $FQFN); + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'baseDir=' . $baseDir . ',baseFile=' . $baseFile . ',FQFN=' . $FQFN); // Exclude this one continue; @@ -1840,7 +1851,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Skip also files with non-matching prefix genericly if (($recursive === true) && (isDirectory($FQFN))) { // Is a redirectory so read it as well - $files = merge_array($files, getArrayFromDirectory($baseDir . $baseFile . '/', $prefix, $fileIncludeDirs, $addBaseDir, $excludeArray, $extension, $excludePattern, $recursive)); + $foundMatches = merge_array($foundMatches, getArrayFromDirectory($baseDir . $baseFile . '/', $prefix, $fileIncludeDirs, $addBaseDir, $excludeArray, $extension, $excludePattern, $recursive)); // And skip further processing continue; @@ -1872,10 +1883,10 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad // Add file with or without base path if ($addBaseDir === true) { // With base path - $files[] = $fileName; + $foundMatches[] = $fileName; } else { // No base path - $files[] = $baseFile; + $foundMatches[] = $baseFile; } } else { // We found .php file but should not search for them, why? @@ -1883,7 +1894,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad } } elseif ($fileExtension == $extension) { // Other, generic file found - $files[] = $fileName; + $foundMatches[] = $fileName; } } // END - while @@ -1891,11 +1902,11 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad closedir($dirPointer); // Sort array - sort($files); + sort($foundMatches); // Return array with include files //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '- Left!'); - return $files; + return $foundMatches; } // Checks wether $prefix is found in $fileName