Jump to content

directory tree


drperic

Recommended Posts

Hy,

 

Im having problems with this code,it returns list of files that have bin created  from yesterday to today,how to Excludes folders that starts with "." or with some name "Example". and how to sort files by time.Any suggestion is welcome

 

<?

$dir='/home/FTP-shared/DISK_1';
$jucer  = mktime(date("h"), date("i"), date("s"), date("m"), date("d")-1, date("Y"));
$datum = date("d-m-Y H:i:s", $jucer);
$comparedatestr=$datum;
$comparedate=strtotime($comparedatestr);

//I run the function here to start the search.
echo "<table class='tablica' cellspacing='0' cellpadding='0'>";
echo "<th>Path</th><th>Dir</th><th>Date</th>";
directory_tree($dir,$comparedate);
echo "</table>";
//This is the function which is doing the search...
function directory_tree($address,$comparedate)
{

@$dir = opendir($address);
  if(!$dir){ return 0; } while($entry = readdir($dir))
  {

                if(is_dir("$address/$entry") && ($entry != ".." && $entry != ".")){
                        directory_tree("$address/$entry",$comparedate);
                }
                 else{
                  if($entry != ".." && $entry != ".")
                  {

                    $fulldir=$address.'/'.$entry;
                    $last_modified = filemtime($fulldir);
                    $last_modified_str= date("d-m-Y H:i:s", $last_modified);
                       if($comparedate < $last_modified)  {
                          echo "<tr>";
                          echo "<td>" . substr_replace($address,'',1,23) . "</td><td>" . $entry . '</td><td>'.$last_modified_str.'</td>';
                          echo "</tr>";
                       }

                 }

            }


      }

}
?>

Link to comment
https://forums.phpfreaks.com/topic/169345-directory-tree/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.