This function was widely inspired by dwebb's File Search function (see: http://www.zend.com/codex.php?id=301&single=1) It's basically the same function but now it returns an array to support multiple matches, it's also more flexible because I used stristr() instead of a literal match, wich is quite useless for a search function...
Download
View Source (print view)
Rating : 4.7
Views : 448
<?php
/*----------------------------------------------------------[v2.0]--+
| function search($dir,$needle,$recurse=false) |
| |
| Inputs |
| @param str dir valid path to search in |
| @param str needle keyword to match |
| @param bol recurse recursive search (default false) |
| |
| Outputs |
| - false: no match |
| - array: list of matches |
| |
| Author: h3 |
| mail: h3@mindkind.org |
| credits: widely inspired from dwebb's File Search function |
| (see: http://www.zend.com/codex.php?id=301&single=1) |
| |
+------------------------------------------------------------------*/
function search($dir,$needle,$recurse=false) {
if(is_dir($dir)) {
$handle = @opendir($dir);
$o = array();
while($file=readdir($handle)) {
if (($file=='.')||($file=='..')) continue;
if(stristr(strtolower($file),strtolower($needle))) {
$o[] = $dir.$file;
}
if(is_dir($dir.'/'.$file)&&$recurse==true) {
$subresults = search($dir.'/'.$file,$needle,true);
if(!empty($subresults)) {
$o = array_merge($o,$subresults);
}
}
}
if(!empty($o)) {
return $o;
} else {
return false;
}
}
}
?>
user status in online, dgh9y5vo="neww"_target="_blank"_title="im_neuen_fens, rtttl to 8 bit source code, files, php script" class="neww" target="_b... and 0=1 union select, php tools and 0=1 union select, rtttl, read mysql field, security, snnap_ss, salars77, paper_without_wood, guest, enfactuation, rent a car, download, regirstration form, php_snips, fedex, call php'