Skip to content

Instantly share code, notes, and snippets.

@prasanjit-
Created February 5, 2020 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prasanjit-/2ceaf4061a4b388dd2285343f13de957 to your computer and use it in GitHub Desktop.
Save prasanjit-/2ceaf4061a4b388dd2285343f13de957 to your computer and use it in GitHub Desktop.
<?php
//Php Script to detect the files changed in a project recursively after a certain date
//Put here the directory you want to search for. Put / if you want to search your entire domain
$dir='/path/to/public_html';
//Put the date you want to compare with in the format of: YYYY-mm-dd hh:mm:ss
$comparedatestr="2020-01-21 00:00:00";
$comparedate=strtotime($comparedatestr);
//I run the function here to start the search.
directory_tree($dir,$comparedate);
//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("Y-m-d h:i:s", $last_modified);
if($comparedate < $last_modified) {
echo $fulldir.'=>'.$last_modified_str;
echo "<BR>";
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment