} // 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__."(<font color=\"#0000aa\">".__LINE__."</font>):dir=".$dir."<br />\n";
+ $ds = GET_DIR_AS_ARRAY($dir, "", true, false);
+ //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):ds[]=".count($ds)."<br />\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__."(<font color=\"#0000aa\">".__LINE__."</font>):FQFN={$FQFN}<br />\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__."(<font color=\"#0000aa\">".__LINE__."</font>):DESCENT: ".$newDir."<br />\n";
+ searchDirsRecursive($newDir, $last_changed);
+ } elseif (FILE_READABLE($FQFN)) {
+ // $FQFN is a filename and no directory
+ $time = filemtime($FQFN);
+ //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):File: ".$d." found. (".($last_changed['time'] - $time).")<br />\n";
+ if ($last_changed['time'] < $time) {
+ // This file is newer as the file before
+ //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>) - NEWER!<br />\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... ;-)
function getAkt_vers () {
// Init variables
- $next_dir = ".";
+ $next_dir = "";
$last_changed = array(
'path_name' => "",
'time' => 0
$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']);
}
// 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
// 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__."(<font color=\"#0000aa\">".__LINE__."</font>):baseDir={$baseDir},prefix={$prefix},baseFile={$baseFile}<br />\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);
// Is the extension valid and active?
if (($extId > 0) && (EXT_IS_ACTIVE($extName))) {
// Then add this file
+ //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Extension entry ".$baseFile." added.<br />\n";
$INCs[] = $INC;
} elseif ($extId == 0) {
// Add non-extension files as well
- $INCs[] = $INC;
+ //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): Regular entry ".$baseFile." added.<br />\n";
+ if ($addBaseDir) {
+ $INCs[] = $INC;
+ } else {
+ $INCs[] = $baseFile;
+ }
}
} // END - if
} // END - while
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 //
//////////////////////////////////////////////////