X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=815e6f72dd98e4dcc7f44929ebad98b02e167bdd;hp=90c2bdbed1182808ca97e9b66ec7a612ad9ef819;hb=2b388c21a07e07317ccb065d42ef7304cfca7718;hpb=4ba0d29f12dae79ebde25004a1df4155e0faf69c diff --git a/inc/functions.php b/inc/functions.php index 90c2bdbed1..815e6f72dd 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2525,27 +2525,43 @@ function clearOutputBuffer () { } // END - if } -// Function to search for the last modifikated file -function searchDirsRecoursive ($dir, &$last_changed) { - $ds = scandir($dir); // Needs adjustment for PHP < 5.0.0!! +// Function to search for the last modifified file +function searchDirsRecursive ($dir, &$last_changed) { + // Get dir as array + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):dir=".$dir."
\n"; + $ds = GET_DIR_AS_ARRAY($dir, "", true, false); + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):ds[]=".count($ds)."
\n"; + + // Walk through all entries foreach ($ds as $d) { - $f_name = $dir.'/'.$d; // makes a proper Filename - if (!preg_match('@(\.|\.\.|\.revision|\.svn|debug\.log|\.cache)$@',$d)) { // no . or .. or .revision or .svn in the filename - $is_dir = is_dir($f_name); - if (!$is_dir) { // $f_name is a filename and no directory - $time = filemtime($f_name); - if ($last_changed['time'] < $time) { // This file is newer as the file before - $last_changed['path_name'] = $f_name; + // Generate proper FQFN + $FQFN = str_replace("//", "/", constant('PATH') . $dir. "/". $d); + + // Does it match what we are looking for? (We skip a lot files already!) + if (!preg_match('@(\.|\.\.|\.revision|\.svn|debug\.log|\.cache)$@', $d)) { // no . or .. or .revision or .svn in the filename + // Is it a file and readable? + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):FQFN={$FQFN}
\n"; + if (isDirectory($FQFN)) { + // $FQFN is a directory so also crawl into this directory + $newDir = $d; + if (!empty($dir)) $newDir = $dir . "/". $d; + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):DESCENT: ".$newDir."
\n"; + searchDirsRecursive($newDir, $last_changed); + } elseif (FILE_READABLE($FQFN)) { + // $FQFN is a filename and no directory + $time = filemtime($FQFN); + //* DEBUG: */ print __FUNCTION__."(".__LINE__."):File: ".$d." found. (".($last_changed['time'] - $time).")
\n"; + if ($last_changed['time'] < $time) { + // This file is newer as the file before + //* DEBUG: */ print __FUNCTION__."(".__LINE__.") - NEWER!
\n"; + $last_changed['path_name'] = $FQFN; $last_changed['time'] = $time; - } - } elseif ($is_dir) { // $f_name is a directory so also crawl into this directory - searchDirsRecoursive($f_name, $last_changed); + } // END - if } - } - } + } // END - if + } // END - foreach } - // "Getter" for revision/version data function getActualVersion ($type = 'Revision') { // By default nothing is new... ;-) @@ -2624,7 +2640,7 @@ function getSearchFor () { function getAkt_vers () { // Init variables - $next_dir = "."; + $next_dir = ""; $last_changed = array( 'path_name' => "", 'time' => 0 @@ -2633,7 +2649,7 @@ function getAkt_vers () { $res = 0; // Searches all Files and there date of the last modifikation and puts the newest File in $last_changed. - searchDirsRecoursive($next_dir, $last_changed); + searchDirsRecursive($next_dir, $last_changed); // Get file $last_file = READ_FILE($last_changed['path_name']); @@ -3071,7 +3087,8 @@ function DEBUG_LOG ($funcFile, $line, $message, $force=true) { } // Reads a directory with PHP files in and gets only files back -function GET_DIR_AS_ARRAY ($baseDir, $prefix) { +function GET_DIR_AS_ARRAY ($baseDir, $prefix, $includeDirs = false, $addBaseDir = true) { + // Init includes $INCs = array(); // Open directory @@ -3079,13 +3096,13 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) { // Read all entries while ($baseFile = readdir($dirPointer)) { - // Load file only if extension is active - $INC = $baseDir.$baseFile; + // Construct include filename and FQFN + $INC = $baseDir . "/" . $baseFile; $FQFN = constant('PATH') . $INC; // Is this a valid reset file? //* DEBUG: */ print __FUNCTION__."(".__LINE__."):baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}
\n"; - if ((FILE_READABLE($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) { + if (((FILE_READABLE($FQFN)) && (substr($baseFile, 0, strlen($prefix)) == $prefix) && (substr($baseFile, -4, 4) == ".php")) || (($includeDirs) && (isDirectory($FQFN)))) { // Remove both for extension name $extName = substr($baseFile, strlen($prefix), -4); @@ -3095,10 +3112,16 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) { // Is the extension valid and active? if (($extId > 0) && (EXT_IS_ACTIVE($extName))) { // Then add this file + //* DEBUG: */ print __FUNCTION__."(".__LINE__."): Extension entry ".$baseFile." added.
\n"; $INCs[] = $INC; } elseif ($extId == 0) { // Add non-extension files as well - $INCs[] = $INC; + //* DEBUG: */ print __FUNCTION__."(".__LINE__."): Regular entry ".$baseFile." added.
\n"; + if ($addBaseDir) { + $INCs[] = $INC; + } else { + $INCs[] = $baseFile; + } } } // END - if } // END - while @@ -3570,6 +3593,18 @@ function isUserIdSet () { return (isset($GLOBALS['userid'])); } +// Checks wether the given FQFN is a directory and not .,.. or .svn +function isDirectory ($FQFN) { + // Generate baseName + $baseName = basename($FQFN); + + // Check it + $isDirectory = ((is_dir($FQFN)) && ($baseName != ".") && ($baseName != "..") && ($baseName != ".svn")); + + // Return the result + return $isDirectory; +} + ////////////////////////////////////////////////// // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS // //////////////////////////////////////////////////