PHP -Search for a file on a site
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.


value="" />


" />



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
?>
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