Here is a script I wrote to help me find files on my php server. You enter the text to search for and it will return a list of files and directories that contain the search term.
searchDirectory($_REQUEST["dir"],0,$_REQUEST["searchterm"]); }
function searchDirectory( $path = '.', $level = 0, $searchterm='' ){ $ignore = array( 'cgi-bin', '.', '..' ); $dh = ( $path );
while( false !== ( $file = readdir( $dh ) ) ){ // Loop through the directory if( !in_array( $file, $ignore ) ){ if(checkFile($file,$searchterm)){ echo "$path/$file "; } if( is_dir( "$path/$file" ) ){ searchDirectory( "$path/$file", ($level+1),$searchterm); }//if }//if in array> }//while
closedir( $dh );
}//function
function checkFile( $file = '', $searchterm='' ){ $file = strtolower($file); $searchterm = strtolower($searchterm); if(strpos($file , $searchterm)){ return true; } return false; }//function ?>
|