PHP - What files on a site have been modified?

Recently I had to search through a php site to find what files had recently been recently modified. I wrote a script to do it heavily based on this one at coding forums posted by missing-score.

Here is the code I used:

 


function getDirectory( $path = ‘.’, $level = 0 ,$time){
$ignore = array( ‘cgi-bin’, ‘.’, ‘..’ );
$dh = ( $path );
while( false !== ( $file = readdir( $dh ) ) ){ // Loop through the directory
if( !in_array( $file, $ignore ) ){
if( is_dir( “$path/$file” ) ){
// Its a directory, so we need to keep reading down…
getDirectory( “$path/$file”, ($level+1),$time );
} else {
if(filemtime(”$path/$file”)>$time){
echo “ $path/$file Last modified ” . date(”l, dS F, Y @ h:ia”, filemtime(”$path/$file”)).”
“;
}
}//elseif

}//if in array

}//while
closedir( $dh );
}//function
?>

Basically it loops over you directory structure starting from the base path you feed the function and spits out any files that have been modified after the timestamp you feed the function.

Comments
Add New
Powered by !JoomlaComment 3.26

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

 

Help my beer fund

RocketTheme Joomla Templates