In order to figure out how to test for the time, etc., I needed to reformat and slightly rewrite the function. The main changes were to use an array for the skipped-over files (to shorten the function), use a "foreach" instead of a "for" loop, and use "is_dir" instead of testing for the absence of a ".". Oh, and I needed to add a couple more arguments to the function call. The age of the file is tested for and old directories are skipped over by the code in the three lines after "if (is_dir($value))". There's still a problem--empty directories. I'll leave that to you. I hope this helps you now and in your future coding.
$max_age = 30 * 24 * 60 * 60; // Thirty days
$base_dir = '.';
$file_dir = $base_dir;
create_tree($base_dir, $file_dir, $max_age);
function create_tree($base_dir, $file_dir, $max_age)
{
$no_no_arr = array('.', '..', 'list.php', 'AlbumCover.jpg',
'AlbumInfo.txt', 'info.txt', 'WS_FTP.LOG',
'_Browse by genre');
if ($handle = @opendir($file_dir)) {
while (false !== ($file = @readdir($handle))) {
if (!in_array($file, $no_no_arr)) {
$list[] = $file;
}
}
echo '<ul>';
foreach ($list as $value) {
if (is_dir($value)) {
$filepath = $base_dir . '/' . $file_dir . '/' . $value . '/';
if ((filemtime($filepath) + $max_age) < time()) {
continue;
}
echo '<img src="/images/c-list.gif">' .
'<font face="verdana" size="2"><b>' .
$value . '</b>' . '</font>' . "\n";
create_tree($base_dir, $file_dir . '/' . $value, $max_age);
} else {
echo '<font face="verdana" size="1"><a href="' .
$file_dir . '/' . $value . '" target="_blank">' .
'<img src="/images/a-home.gif" border="0">' .
substr($value, 0, -4) . '</a><br></font>' . "\n";
}
}
echo '</ul>';
closedir($handle);
}
}